Package net.sourceforge.jpowergraph.swtswinginteraction.geometry

Examples of net.sourceforge.jpowergraph.swtswinginteraction.geometry.JPowerGraphDimension


        int imageWidth = 18;
        int imageHeight = 8;
        int stringWidth = stringWidth(g, legendText);
        int width = imageWidth + stringWidth + (padding * 3);
        int height = Math.max(imageHeight, g.getAscent() + g.getDescent() + 4);
        return new JPowerGraphDimension(width, height);
    }
View Full Code Here


        g.setForeground(getBorderColor(node, graphPane, theSubGraphHighlighter));
        g.drawOval(thePoint.x - radius / 2, thePoint.y - radius / 2, radius, radius);

        if (showNodes){
            JPowerGraphGraphics subG = g.getSubJPowerGraphGraphics(new JPowerGraphDimension(dummyRectangle.width, dummyRectangle.height));
            double scale = getInstanceScale(numInstances);
           
            subG.setBackground(g.getBackground());
            subG.setForeground(g.getForeground());
            subG.setAntialias(g.getAntialias());
            subG.fillRectangle(0, 0, dummyRectangle.width, dummyRectangle.height);
            nodePainter.paintNode(graphPane, subG, dummyNode, ShapeNodePainter.SMALL, theSubGraphHighlighter, new JPowerGraphPoint(dummyRectangle.width/2, dummyRectangle.height/2), scale);
            JPowerGraphColor nodeColor = nodePainter.getBackgroundColor(dummyNode, graphPane, theSubGraphHighlighter);
           
            for (int i = 0; i < rowSizes.length; i++) {
                int rowIndex = (((numRows - 1) / 2) - i) * -1;
                int normalisedRowIndex = rowIndex;
                if (normalisedRowIndex < 0){
                    normalisedRowIndex *= -1;
                }
   
                int rowdx = 0;
               
                int numFullNodes = 0;
                int numHalfNodes = 0;
                int numGaps = 0;
                if (i % 2 != 0) {
                    numFullNodes = (rowSizes[i] - 2);
                    numHalfNodes = 1;
                    numGaps = (rowSizes[i] - 1);
                }
                else{
                    numFullNodes = (rowSizes[i] - 1);
                    numHalfNodes = 0;
                    numGaps = (rowSizes[i] - 1);
                }
                rowdx = (numFullNodes * dummyRectangle.width) + (numHalfNodes * dummyRectangle.width) + (numGaps * hPadBetweenInstances) ;
                rowdx = rowdx / 2;
               
                JPowerGraphGraphics rowG = rowImageMap.retrieve(scale, rowSizes[i], g.getBackground(), nodeColor);
                if (rowG == null){
                    int rowWidth = (dummyRectangle.width + hPadBetweenInstances) * rowSizes[i] + 1;
                    rowG = g.getSubJPowerGraphGraphics(new JPowerGraphDimension(rowWidth, dummyRectangle.height));
                    rowG.setBackground(g.getBackground());
                    rowG.setForeground(g.getForeground());
                    rowG.setAntialias(g.getAntialias());
                    rowG.fillRectangle(0, 0, rowWidth, dummyRectangle.height);
                    for (int j = 0; j < rowSizes[i]; j++) {
View Full Code Here

        int imageWidth = 18;
        int imageHeight = 8;
        int stringWidth = stringWidth(graphPane.getJPowerGraphGraphics(), legendText);
        int width = imageWidth + stringWidth + (padding * 3);
        int height = Math.max(imageHeight, graphPane.getJPowerGraphGraphics().getAscent() + graphPane.getJPowerGraphGraphics().getDescent() + 4);
        return new JPowerGraphDimension(width, height);
    }
View Full Code Here

        SWTJPowerGraphGraphics main = new SWTJPowerGraphGraphics(this, e.gc, colourManager);
        if (buffer == null || (buffer.getImage().getBounds().width != getWidth() || buffer.getImage().getBounds().height != getHeight())){
            if (buffer != null){
                buffer.dispose();
            }
            buffer = (SWTJPowerGraphGraphics) main.getSubJPowerGraphGraphics(new JPowerGraphDimension(getWidth(), getHeight()));
        }
        else{
            buffer.reset();
            buffer.fillRectangle(0, 0, getWidth(), getHeight());
        }
View Full Code Here

    public void paintLegendItem(final JGraphPane graphPane, JPowerGraphGraphics g, LegendItem legendItem, Legend theLegend, JPowerGraphPoint thePoint, JPowerGraphRectangle theLegendRectangle) {
        if (legendItem instanceof NodeLegendItem){
            final NodeLegendItem nodeLegendItem = (NodeLegendItem) legendItem;

            JPowerGraphDimension d = nodeLegendItem.getNodePainter().getLegendItemSize(graphPane, nodeLegendItem.getDescription());
            nodeLegendItem.getNodePainter().paintLegendItem(g, thePoint, nodeLegendItem.getDescription());
           
            if (graphPane.getGraph().getNodeFilter() != null && theLegend.isInteractive()){
                int buttonX = theLegendRectangle.x + (theLegendRectangle.width - (buttonWidth + widthPadding));
                int buttonY = thePoint.y - heightpadding;
                int buttonHeight = d.getHeight() - 5;
               
                boolean canFilterNode = graphPane.getGraph().getNodeFilter().canChangeFilterState(nodeLegendItem.getNodeClass());
                boolean isChecked = graphPane.getGraph().getNodeFilter().getFilterState(nodeLegendItem.getNodeClass());
                JPowerGraphRectangle r = new JPowerGraphRectangle(buttonX, buttonY, buttonWidth, buttonHeight);
                if (canFilterNode){
                    g.setForeground(enabledButtonColor);
                    theLegend.addActionRectangle(r, new AbstractAction() {
                        public void actionPerformed(ActionEvent e) {
                            graphPane.getGraph().getNodeFilter().setFilterState(nodeLegendItem.getNodeClass(), !graphPane.getGraph().getNodeFilter().getFilterState(nodeLegendItem.getNodeClass()));
                        }
                    });
                }
                else{
                    g.setForeground(disabledButtonColor);
                }
               
                g.drawRectangle(r.x, r.y, r.width, r.height);
                if (isChecked){
                    g.drawLine(r.x + 3, r.y + 3, r.x + r.width - 3, r.y + r.height - 3);
                    g.drawLine(r.x + 3, r.y + r.height - 3, r.x + r.width - 3, r.y + 3);
                }
            }
        }
        else if (legendItem instanceof GroupLegendItem){
            final GroupLegendItem groupLegendItem = (GroupLegendItem) legendItem;
            if (groupLegendItem.getLegendItems().size() > 0){
                JPowerGraphRectangle r = new JPowerGraphRectangle(thePoint.x + 5, thePoint.y, toggleWidth - 10, toggleHeight);
               
                theLegend.addActionRectangle(r, new AbstractAction() {
                    public void actionPerformed(ActionEvent e) {
                        groupLegendItem.setExpanded(!groupLegendItem.isExpanded());
                        graphPane.redraw();
                    }
                });
               
                g.setForeground(enabledButtonColor);
                g.drawLine(r.x, r.y + r.height/2, r.x + r.width, r.y + r.height/2);
                g.drawString(groupLegendItem.getDescription(), r.x + r.width + 5, r.y - 2, 1);
                if (groupLegendItem.isExpanded()){
                    JPowerGraphPoint subPoint = new JPowerGraphPoint(thePoint.x + indent, thePoint.y + Math.max(toggleHeight, g.getAscent() + g.getDescent() + 4));
                    for (LegendItem subLegendItem : groupLegendItem.getLegendItems()) {
                        JPowerGraphDimension subDimension = new JPowerGraphDimension(0, 0);
                        getLegendItemSize(graphPane, subLegendItem, theLegend, subDimension);
                        paintLegendItem(graphPane, g, subLegendItem, theLegend, subPoint, theLegendRectangle);
                        subPoint.y += subDimension.height;
                    }
                }
View Full Code Here

        }
    }
   
    public void getLegendItemSize(JGraphPane graphPane, LegendItem legendItem, Legend theLegend, JPowerGraphDimension theDimension) {
        if (legendItem instanceof NodeLegendItem){
            JPowerGraphDimension dimension = ((NodeLegendItem) legendItem).getNodePainter().getLegendItemSize(graphPane, legendItem.getDescription());
            theDimension.width = Math.max(theDimension.width, dimension.width);
            theDimension.height += dimension.height;
           
            if (graphPane.getGraph().getNodeFilter() != null  && theLegend.isInteractive()){
                theDimension.width += buttonWidth + widthPadding;
            }
        }
        else if (legendItem instanceof GroupLegendItem){
            if (((GroupLegendItem) legendItem).getLegendItems().size() > 0){
                JPowerGraphGraphics g = graphPane.getJPowerGraphGraphics();
                theDimension.width = Math.max(theDimension.width, g.getStringWidth(((GroupLegendItem) legendItem).getDescription()) + toggleWidth + 5);
                theDimension.height += Math.max(toggleHeight, g.getAscent() + g.getDescent() + 4);
               
                if (((GroupLegendItem) legendItem).isExpanded()){
                    for (LegendItem subLegendItem : ((GroupLegendItem) legendItem).getLegendItems()) {
                        JPowerGraphDimension subDimension = new JPowerGraphDimension (0, 0);
                        this.getLegendItemSize(graphPane, subLegendItem, theLegend, subDimension);
                        theDimension.width = Math.max(theDimension.width, subDimension.width + indent);
                        theDimension.height += subDimension.height;
                    }
                }
View Full Code Here

        int heightPad = 8;
        LegendItemPainter painter = new LegendItemPainter();
       
        height = heightPad;
        for (LegendItem legendItem : theLegend.getRoot().getLegendItems()) {
            JPowerGraphDimension dimension = new JPowerGraphDimension(0, 0);
            painter.getLegendItemSize(graphPane, legendItem, theLegend, dimension);
            if (dimension.width != widthPad && dimension.height != heightPad){
                width = Math.max(width, dimension.width + widthPad);
                height += dimension.height;
            }
        }
        JPowerGraphRectangle legendRectangle = new JPowerGraphRectangle(10, graphPane.getHeight() - (height + 10), width, height);
       
        JPowerGraphColor oldColor = g.getForeground();
        g.setForeground(white);
        g.fillRoundRectangle(legendRectangle.x, legendRectangle.y, legendRectangle.width, legendRectangle.height, 10, 10);
        g.setForeground(black);
        g.drawRoundRectangle(legendRectangle.x, legendRectangle.y, legendRectangle.width, legendRectangle.height, 10, 10);
        g.setForeground(oldColor);
       
        JPowerGraphPoint point = new JPowerGraphPoint(legendRectangle.x + widthPad/2, legendRectangle.y + heightPad);
        for (LegendItem legendItem : theLegend.getRoot().getLegendItems()) {
            JPowerGraphDimension dimension = new JPowerGraphDimension(0, 0);
            painter.getLegendItemSize(graphPane, legendItem, theLegend, dimension);
            painter.paintLegendItem(graphPane, g, legendItem, theLegend, point, legendRectangle);
            point.y += dimension.height;
        }
       
View Full Code Here

TOP

Related Classes of net.sourceforge.jpowergraph.swtswinginteraction.geometry.JPowerGraphDimension

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.