Search in sources :

Example 46 with Dimension

use of org.eclipse.draw2d.geometry.Dimension in project cubrid-manager by CUBRID.

the class ERMinJoinDirectedGraphLayout method buildAverageOffset.

public Dimension buildAverageOffset(ERTableNode basicNode, List<ERTableNode> allNode, Ray ray) {
    int count = allNode.size();
    Dimension sumD = new Dimension(0, 0);
    for (int i = 0; i < count; i++) {
        Dimension tmpD = buildDefaultCenterOffset(basicNode, allNode.get(i), ray);
        sumD.width += tmpD.width;
        sumD.height += tmpD.height;
    }
    sumD.width = sumD.width / count;
    sumD.height = sumD.height / count;
    return sumD;
}
Also used : Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point)

Example 47 with Dimension

use of org.eclipse.draw2d.geometry.Dimension in project cubrid-manager by CUBRID.

the class ERMinJoinDirectedGraphLayout method layout2.

private void layout2(Ray ray) {
    ERTableNode node1 = joinDirectedGraph.getNode(0);
    ERTableNode node2 = joinDirectedGraph.getNode(1);
    Dimension dimension1 = node1.getDefaultPreferredSize();
    Dimension dimension2 = node2.getDefaultPreferredSize();
    if (dimension2.height > dimension1.height) {
        initNodeVetexCoordinate(node2);
        buildRelationNodeXY(node2, node1, ray);
    } else {
        initNodeVetexCoordinate(node1);
        buildRelationNodeXY(node1, node2, ray);
    }
}
Also used : Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 48 with Dimension

use of org.eclipse.draw2d.geometry.Dimension in project cubrid-manager by CUBRID.

the class GraphPlanStyleProvider method selfStyleNode.

public void selfStyleNode(Object element, GraphNode node) {
    if (element instanceof PlanNode) {
        PlanNode planNode = (PlanNode) element;
        CompartmentFigure figure = (CompartmentFigure) node.getNodeFigure();
        String title = planNode.getMethod();
        if (planNode.getTable() != null) {
            title += "(" + planNode.getTable().getName() + ")";
        }
        figure.setTitle(title);
        GraphPlanTooltipFigure tooltip = new GraphPlanTooltipFigure();
        figure.setToolTip(tooltip);
        Dimension dim = tooltip.getPreferredSize();
        tooltip.setTitle(planNode.getMethod());
        if (planNode.getDepth() == 0) {
            figure.setImage(GraphPlanImageSupport.getDefaultImage());
        } else {
            figure.setImage(GraphPlanImageSupport.getImage(planNode));
        }
        PlanCost cost = planNode.getCost();
        if (cost != null) {
            String costAndCardinality = "";
            costAndCardinality += "cost: " + cost.getTotal();
            tooltip.addKeyValueItem("cost", wrapText(dim.width, String.valueOf(cost.getTotal())));
            if (cost.getCard() > 0) {
                costAndCardinality += ", card: " + cost.getCard();
                tooltip.addKeyValueItem("cardinality", wrapText(dim.width, String.valueOf(cost.getCard())));
            }
            figure.setInfo(costAndCardinality);
        }
        if (planNode.getTable() != null && planNode.getTable().getName() != null) {
            tooltip.addKeyValueItem("table", wrapText(dim.width, planNode.getTable().getName()));
        }
        if (planNode.getEdge() != null && planNode.getEdge().getTermString() != null) {
            tooltip.addKeyValueItem("edge", wrapText(dim.width, planNode.getEdge().getTermString()));
        }
        if (planNode.getSargs() != null && planNode.getSargs().getTermString() != null) {
            tooltip.addKeyValueItem("sargs", wrapText(dim.width, planNode.getSargs().getTermString()));
        }
        if (planNode.getIndex() != null && planNode.getIndex().getTermString() != null) {
            tooltip.addKeyValueItem("index", wrapText(dim.width, planNode.getIndex().getTermString()));
        }
        if (planNode.getOrder() != null) {
            tooltip.addKeyValueItem("sort", wrapText(dim.width, planNode.getOrder()));
        }
        figure.show();
    }
}
Also used : PlanNode(com.cubrid.common.core.queryplan.model.PlanNode) PlanCost(com.cubrid.common.core.queryplan.model.PlanCost) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 49 with Dimension

use of org.eclipse.draw2d.geometry.Dimension in project cubrid-manager by CUBRID.

the class ReplicationEditor method createDiagram.

/**
	 * create the diagram
	 * 
	 * @param input IEditorInput
	 */
private void createDiagram(IEditorInput input) {
    diagram = new Diagram();
    if (input instanceof ICubridNode) {
        ICubridNode node = (ICubridNode) input;
        if (NodeType.DATABASE.equals(node.getType())) {
            isEditable = false;
            CubridServer server = node.getServer();
            int x = 100;
            int y = 20;
            int hostVertSpan = 100;
            if (server != null) {
                ReplicationInfo replicationInfo = (ReplicationInfo) node.getAdapter(ReplicationInfo.class);
                if (replicationInfo != null) {
                    //distributor component
                    DistributorInfo distInfo = replicationInfo.getDistInfo();
                    DistributorNode dist = null;
                    if (distInfo != null) {
                        dist = new DistributorNode();
                        dist.setDbName(distInfo.getDistDbName());
                        dist.setDbPath(distInfo.getDistDbPath());
                        dist.setCopyLogPath(distInfo.getCopyLogPath());
                        dist.setErrorLogPath(distInfo.getErrorLogPath());
                        dist.setTrailLogPath(distInfo.getTrailLogPath());
                        dist.setReplAgentPort(distInfo.getAgentPort());
                        dist.setDelayTimeLogSize(distInfo.getDelayTimeLogSize());
                        dist.setRestartWhenError(distInfo.isRestartReplWhenError());
                        dist.setName(distInfo.getDistDbName());
                        dist.setLocation(new Point(30, 30));
                        dist.setSize(new Dimension(120, 40));
                    }
                    //master component
                    List<MasterInfo> masterList = replicationInfo.getMasterList();
                    MasterNode master = null;
                    for (int i = 0; masterList != null && i < masterList.size(); i++) {
                        MasterInfo masterInfo = masterList.get(i);
                        if (masterInfo != null) {
                            master = new MasterNode();
                            String ip = masterInfo.getMasterIp();
                            String masterDbName = masterInfo.getMasterDbName();
                            String replServerPort = masterInfo.getReplServerPort();
                            boolean isReplAll = masterInfo.isReplAllTable();
                            List<String> tableList = masterInfo.getReplTableList();
                            HostNode mdbHost = new HostNode();
                            mdbHost.setIp(ip);
                            mdbHost.setUserName("admin");
                            mdbHost.setName(ip);
                            mdbHost.setLocation(new Point(x, y));
                            y += mdbHost.getSize().height + hostVertSpan;
                            mdbHost.setParent(diagram);
                            diagram.addNode(mdbHost);
                            master.setDbName(masterDbName);
                            master.setReplServerPort(replServerPort);
                            master.setReplicateAll(isReplAll);
                            master.setReplicatedClassList(tableList);
                            master.setName(masterDbName);
                            master.setLocation(new Point(30, 80));
                            master.setSize(new Dimension(120, 40));
                            master.setParent(mdbHost);
                            mdbHost.addChildNode(master);
                        }
                    }
                    //distributor host component
                    HostNode distdbhost = new HostNode();
                    distdbhost.setIp(server.getHostAddress());
                    distdbhost.setPort(server.getMonPort());
                    distdbhost.setUserName(server.getUserName());
                    distdbhost.setPassword(server.getPassword());
                    distdbhost.setName(server.getHostAddress() + ":" + server.getMonPort());
                    distdbhost.setLocation(new Point(x, y));
                    distdbhost.setParent(diagram);
                    diagram.addNode(distdbhost);
                    //distributor component
                    if (dist != null) {
                        dist.setParent(distdbhost);
                        distdbhost.addChildNode(dist);
                    }
                    //slave component
                    List<SlaveInfo> slaveInfoList = replicationInfo.getSlaveList();
                    SlaveNode slave = null;
                    for (int i = 0; slaveInfoList != null && i < slaveInfoList.size(); i++) {
                        SlaveInfo slaveInfo = slaveInfoList.get(i);
                        if (slaveInfo != null) {
                            slave = new SlaveNode();
                            slave.setDbName(slaveInfo.getSlaveDbName());
                            slave.setDbPath(slaveInfo.getSlaveDbPath());
                            slave.setDbUser(slaveInfo.getDbUser());
                            slave.setDbPassword(slaveInfo.getPassword());
                            ReplicationParamInfo replParaInfo = slaveInfo.getParamInfo();
                            if (replParaInfo != null) {
                                slave.setParamMap(replParaInfo.getParamMap());
                            }
                            slave.setName(slaveInfo.getSlaveDbName());
                            slave.setLocation(new Point(30, 150));
                            slave.setSize(new Dimension(120, 40));
                            slave.setParent(distdbhost);
                            distdbhost.addChildNode(slave);
                        }
                    }
                }
            }
        }
    }
}
Also used : MasterNode(com.cubrid.cubridmanager.ui.replication.editor.model.MasterNode) SlaveNode(com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode) DistributorInfo(com.cubrid.cubridmanager.core.replication.model.DistributorInfo) HostNode(com.cubrid.cubridmanager.ui.replication.editor.model.HostNode) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) Point(org.eclipse.draw2d.geometry.Point) Diagram(com.cubrid.cubridmanager.ui.replication.editor.model.Diagram) MasterInfo(com.cubrid.cubridmanager.core.replication.model.MasterInfo) ReplicationParamInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationParamInfo) ReplicationInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationInfo) SlaveInfo(com.cubrid.cubridmanager.core.replication.model.SlaveInfo) DistributorNode(com.cubrid.cubridmanager.ui.replication.editor.model.DistributorNode)

Example 50 with Dimension

use of org.eclipse.draw2d.geometry.Dimension in project knime-core by knime.

the class NodeContainerEditPart method refreshBounds.

/**
 * Adjusts the height and width of the node's figure. It automatically sets them to the preferred height/width of
 * the figure (which might change if the warning icons change). It doesn't change x/y position of the figure. It
 * does change width and height.
 */
private void refreshBounds() {
    NodeUIInformation uiInfo = getNodeContainer().getUIInformation();
    int[] bounds = uiInfo.getBounds();
    WorkflowRootEditPart parent = (WorkflowRootEditPart) getParent();
    NodeContainerFigure fig = (NodeContainerFigure) getFigure();
    Dimension pref = fig.getPreferredSize();
    boolean set = false;
    if (pref.width != bounds[2]) {
        bounds[2] = pref.width;
        set = true;
    }
    if (pref.height != bounds[3]) {
        bounds[3] = pref.height;
        set = true;
    }
    if (set) {
        // notify uiInfo listeners (e.g. node annotations)
        m_uiListenerActive = false;
        getNodeContainer().setUIInformation(NodeUIInformation.builder().setNodeLocation(bounds[0], bounds[1], bounds[2], bounds[3]).build());
        m_uiListenerActive = true;
    }
    // since ver2.3.0 all coordinates are relative to the icon
    Point offset = fig.getOffsetToRefPoint(uiInfo);
    bounds[0] -= offset.x;
    bounds[1] -= offset.y;
    Rectangle rect = new Rectangle(bounds[0], bounds[1], bounds[2], bounds[3]);
    fig.setBounds(rect);
    parent.setLayoutConstraint(this, fig, rect);
}
Also used : NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point) NodeContainerFigure(org.knime.workbench.editor2.figures.NodeContainerFigure)

Aggregations

Dimension (org.eclipse.draw2d.geometry.Dimension)180 Rectangle (org.eclipse.draw2d.geometry.Rectangle)80 Point (org.eclipse.draw2d.geometry.Point)70 IFigure (org.eclipse.draw2d.IFigure)31 List (java.util.List)16 Insets (org.eclipse.draw2d.geometry.Insets)10 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)8 PointList (org.eclipse.draw2d.geometry.PointList)6 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)6 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)6 PrecisionRectangle (org.eclipse.draw2d.geometry.PrecisionRectangle)5 ArrayList (java.util.ArrayList)4 PrecisionPoint (org.eclipse.draw2d.geometry.PrecisionPoint)4 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)4 Font (org.eclipse.swt.graphics.Font)4 Point (org.eclipse.swt.graphics.Point)4 AbstractContainerModel (org.csstudio.opibuilder.model.AbstractContainerModel)3 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)3 Label (org.eclipse.draw2d.Label)3 SimpleHtmlFigure (org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure)3