当前位置: 首页>>代码示例>>Java>>正文


Java GraphicsDecorator.setColor方法代码示例

本文整理汇总了Java中edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator.setColor方法的典型用法代码示例。如果您正苦于以下问题:Java GraphicsDecorator.setColor方法的具体用法?Java GraphicsDecorator.setColor怎么用?Java GraphicsDecorator.setColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator的用法示例。


在下文中一共展示了GraphicsDecorator.setColor方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawFrame

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
private void drawFrame(GraphicsDecorator g, Shape shape, Color color, Point2D.Float pos) {
    Shape old_clip = g.getClip();
    AffineTransform old = g.getTransform();
    AffineTransform t = g.getTransform();
    t.concatenate(AffineTransform.getTranslateInstance(pos.x, pos.y));
    g.setTransform(t);
    g.setColor(color);
    Stroke old_stroke = g.getStroke();
    g.setStroke(new BasicStroke(10.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND));
    Area a = new Area(g.getClip());
    a.subtract(new Area(shape));
    g.setClip(a);
    g.draw(shape);
    g.setTransform(old);
    g.setStroke(old_stroke);
    g.setClip(old_clip);
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:18,代码来源:ViwnVertexRenderer.java

示例2: renderSet

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
private void renderSet(
        RenderContext<ViwnNode, ViwnEdge> rc,
        Point2D p,
        ViwnNodeSet node) {
    GraphicsDecorator g = rc.getGraphicsContext();
    String text = "" + node.getSynsets().size();

    Font f = new Font("Sansserif", Font.BOLD, 14);
    Font old_font = g.getFont();
    g.setFont(f);

    FontMetrics metrics = g.getFontMetrics(g.getFont());
    int width = metrics.stringWidth(text);
    int height = metrics.getHeight();

    g.setColor(Color.black);
    g.drawString(text,
            (int) p.getX() - width / 2,
            (int) p.getY());

    width = metrics.stringWidth("...");
    g.drawString("...",
            (int) p.getX() - width / 2,
            (int) p.getY() + 0.25f * height);
    g.setFont(old_font);
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:27,代码来源:ViwnVertexRenderer.java

示例3: drawVertexArea

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
private void drawVertexArea(ViwnNodeSynset.State state, Shape shape, boolean horiz, GraphicsDecorator g) {
    switch (state) {
        case NOT_EXPANDED:
            g.setColor(Color.blue);
            g.fill(shape);
            break;

        case EXPANDED:
            g.setColor(Color.red);
            g.fill(shape);
            break;

        case SEMI_EXPANDED:
            Rectangle old_clip = g.getClipBounds();
            Rectangle rect = shape.getBounds();

            g.clipRect(rect.x, rect.y, rect.width, rect.height);
            g.setColor(Color.red);
            g.fill(shape);

            if (horiz) {
                g.clipRect(rect.x + rect.width / 2, rect.y,
                        rect.width, rect.height);
            } else {
                g.clipRect(rect.x, rect.y + rect.height / 2,
                        rect.width, rect.height);
            }
            g.setColor(Color.blue);
            g.fill(shape);
            g.setClip(old_clip);
            break;
    }
    g.setColor(Color.black);
    g.draw(shape);
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:36,代码来源:ViwnVertexRenderer.java

示例4: renderLexiconMarker

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
private void renderLexiconMarker(ViwnNodeSynset node, Point2D.Float pos,
                                 GraphicsDecorator g) {

    Shape lexicon = new Area(new RoundRectangle2D.Float(pos.x - 40, pos.y - 17, 23, 10, 12.5f, 5));
    g.setColor(ViwnNodeSynset.PosBgColors.get(node.getPos()));
    g.fillRoundRect(Math.round(pos.x - 40), Math.round(pos.y - 17), 23, 10, 12, 5);
    g.setColor(Color.black);
    g.draw(lexicon);
    Font smallFont = new Font("Tahoma", Font.BOLD, 6);
    g.setFont(smallFont);
    g.drawString(node.getLexiconLabel(), pos.x - 38, pos.y - 10);

}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:14,代码来源:ViwnVertexRenderer.java

示例5: renderWord

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
private void renderWord(
        RenderContext<ViwnNode, ViwnEdge> rc,
        Point2D p,
        ViwnNodeWord node) {
    GraphicsDecorator g = rc.getGraphicsContext();
    String text = node.getLabel();

    FontMetrics metrics = g.getFontMetrics(g.getFont());
    int width = metrics.stringWidth(text);

    g.setColor(Color.black);
    g.drawString(text,
            (int) p.getX() - width / 2,
            (int) p.getY() + 5);
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:16,代码来源:ViwnVertexRenderer.java

示例6: labelEdge

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
@Override
public void labelEdge(RenderContext<V, E> rc, Layout<V, E> layout, E e, String label) {
    if (Strings.isNullOrEmpty(label)) {
        return;
    }

    Shape edgeShape = JungUtils.getTransformedEdgeShape(rc, layout, e);

    if (edgeShape == null) {
        return;
    }

    Line2D line = JungUtils.getLineInMiddle(edgeShape);

    GraphicsDecorator g = rc.getGraphicsContext();
    Font font = rc.getEdgeFontTransformer().transform(e);
    double width = font.getStringBounds(label, g.getFontRenderContext()).getWidth();
    AffineTransform old = g.getTransform();
    AffineTransform trans = new AffineTransform(old);
    double angle = Math.atan2(line.getY2() - line.getY1(), line.getX2() - line.getX1());

    if (angle < -Math.PI / 2) {
        angle += Math.PI;
    } else if (angle > Math.PI / 2) {
        angle -= Math.PI;
    }

    trans.translate(line.getX1(), line.getY1());
    trans.rotate(angle);
    g.setTransform(trans);
    g.setColor(rc.getPickedEdgeState().isPicked(e) ? Color.GREEN : Color.BLACK);
    g.setFont(rc.getEdgeFontTransformer().transform(e));
    g.drawString(label, (int) (-width / 2), 0);
    g.setTransform(old);
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:36,代码来源:BetterEdgeLabelRenderer.java

示例7: paintShapeForVertex

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
protected void paintShapeForVertex(RenderContext<V, E> rc, V v, Shape shape) {
    GraphicsDecorator g = rc.getGraphicsContext();
    Paint oldPaint = g.getPaint();
    Paint fillPaint = rc.getVertexFillPaintTransformer().transform(v);
    if (fillPaint != null) {
        g.setPaint(fillPaint);
        g.fill(shape);
        g.setPaint(oldPaint);
    }
    Paint drawPaint = rc.getVertexDrawPaintTransformer().transform(v);
    if (drawPaint != null) {
        g.setPaint(drawPaint);
        Stroke oldStroke = g.getStroke();
        Stroke stroke = rc.getVertexStrokeTransformer().transform(v);
        if (stroke != null) {
            g.setStroke(stroke);
        }
        g.draw(shape);
        g.setPaint(oldPaint);
        g.setStroke(oldStroke);
    }

    // leaf: draw frequency colors
    if (graphCreator.isLeaf((String) v)) {
        Tree tree = graphCreator.getTree((String) v);
        Map<String, Integer> countMap = tree.getCounterMap();
        int numberOfLabels = countMap.size();
        int frequencySum = tree.getFrequencySum();

        double height = tree.getFrequencySum() / (double) maxLeafSize
                * (FREQUENCY_BAR_MAX_HEIGHT - FREQUENCY_BAR_MIN_HEIGHT) + FREQUENCY_BAR_MIN_HEIGHT;
        double width = shape.getBounds().getWidth() - 2 * FREQUENCY_BAR_OFFSET_X - 1;
        double xPos = shape.getBounds().getX() + FREQUENCY_BAR_OFFSET_X;
        double yPos = shape.getBounds().getY() + shape.getBounds().getHeight() - FREQUENCY_BAR_OFFSET_Y - height;
        ColorProvider colorProvider = new ColorProvider();
        for (String labelValue : countMap.keySet()) {
            int count = tree.getCount(labelValue);
            double currentWidth = ((double) count / (double) frequencySum) * width;
            Rectangle2D.Double frequencyRect = new Rectangle2D.Double(xPos, yPos, currentWidth, height);
            Attribute label = model.getTrainingHeader().getAttributes().getLabel();
               if (label.isNominal()) {
               	int counter = label.getMapping().mapString(labelValue);
                g.setColor(colorProvider.getPointColor((double) counter / (double) (numberOfLabels - 1)));
                g.fill(frequencyRect);
                g.setColor(Color.BLACK);
                xPos += currentWidth;
            }
        }
        g.setColor(Color.BLACK);
        g.draw(new Rectangle2D.Double(shape.getBounds().getX() + FREQUENCY_BAR_OFFSET_X, yPos, width, height));

        g.setPaint(oldPaint);
    }
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:55,代码来源:TreeModelNodeRenderer.java

示例8: paintShapeForVertex

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
protected void paintShapeForVertex(RenderContext<V, E> rc, V v, Shape shape) {
    GraphicsDecorator g = rc.getGraphicsContext();
    Paint oldPaint = g.getPaint();
    Paint fillPaint = rc.getVertexFillPaintTransformer().transform(v);
    if (fillPaint != null) {
        g.setPaint(fillPaint);
        g.fill(shape);
        g.setPaint(oldPaint);
    }
    Paint drawPaint = rc.getVertexDrawPaintTransformer().transform(v);
    if (drawPaint != null) {
        g.setPaint(drawPaint);
        Stroke oldStroke = g.getStroke();
        Stroke stroke = rc.getVertexStrokeTransformer().transform(v);
        if (stroke != null) {
            g.setStroke(stroke);
        }
        g.draw(shape);
        g.setPaint(oldPaint);
        g.setStroke(oldStroke);

    }

    // leaf: draw frequency colors if nominal
    if (graphCreator.isLeaf((String) v)) {
        Attribute label = model.getTrainingHeader().getAttributes().getLabel();
        if (label.isNominal()) {
            Tree tree = graphCreator.getTree((String) v);
            Map<String, Integer> countMap = tree.getCounterMap();
            int numberOfLabels = countMap.size();
            int frequencySum = tree.getFrequencySum();

            double height = tree.getFrequencySum() / (double) maxLeafSize
                    * (FREQUENCY_BAR_MAX_HEIGHT - FREQUENCY_BAR_MIN_HEIGHT) + FREQUENCY_BAR_MIN_HEIGHT;
            double width = shape.getBounds().getWidth() - 2 * FREQUENCY_BAR_OFFSET_X - 1;
            double xPos = shape.getBounds().getX() + FREQUENCY_BAR_OFFSET_X;
            double yPos = shape.getBounds().getY() + shape.getBounds().getHeight() - FREQUENCY_BAR_OFFSET_Y - height;
            ColorProvider colorProvider = new ColorProvider();
            for (String labelValue : countMap.keySet()) {
                int count = tree.getCount(labelValue);
                double currentWidth = (double) count / (double) frequencySum * width;
                Rectangle2D.Double frequencyRect = new Rectangle2D.Double(xPos, yPos, currentWidth, height);
                int counter = label.getMapping().mapString(labelValue);
                g.setColor(colorProvider.getPointColor((double) counter / (double) (numberOfLabels - 1)));
                g.fill(frequencyRect);

                g.setColor(Color.BLACK);
                xPos += currentWidth;
            }

            g.setPaint(oldPaint);
        }
    }
}
 
开发者ID:rapidminer,项目名称:rapidminer-studio,代码行数:55,代码来源:TreeModelNodeRenderer.java

示例9: labelEdge

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
@Override
public void labelEdge(RenderContext<V, E> rc, Layout<V, E> layout, E e, String label) {
    if (label == null || label.length() == 0) {
        return;
    }

    Graph<V, E> graph = layout.getGraph();
    // don't draw edge if either incident vertex is not drawn
    Pair<V> endpoints = graph.getEndpoints(e);
    V v1 = endpoints.getFirst();
    V v2 = endpoints.getSecond();
    if (!rc.getVertexIncludePredicate().evaluate(Context.<Graph<V, E>, V> getInstance(graph, v1))
            || !rc.getVertexIncludePredicate().evaluate(Context.<Graph<V, E>, V> getInstance(graph, v2))) {
        return;
    }

    Point2D p1 = layout.transform(v1);
    Point2D p2 = layout.transform(v2);
    p1 = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p1);
    p2 = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p2);
    float x1 = (float) p1.getX();
    float y1 = (float) p1.getY();
    float x2 = (float) p2.getX();
    float y2 = (float) p2.getY();

    GraphicsDecorator g = rc.getGraphicsContext();
    float distX = x2 - x1;
    float distY = y2 - y1;
    double totalLength = Math.sqrt(distX * distX + distY * distY);

    double closeness = rc.getEdgeLabelClosenessTransformer().transform(Context.<Graph<V, E>, E> getInstance(graph, e))
            .doubleValue();

    int posX = (int) (x1 + closeness * distX);
    int posY = (int) (y1 + closeness * distY);

    int xDisplacement = 0;
    int yDisplacement = 0;

    xDisplacement = (int) (rc.getLabelOffset() * (distX / totalLength));
    yDisplacement = (int) (rc.getLabelOffset() * (-distY / totalLength));

    AffineTransform old = g.getTransform();
    AffineTransform xform = new AffineTransform(old);
    xform.translate(posX + xDisplacement, posY + yDisplacement);

    double parallelOffset = 0.0d;
    Component component = prepareRenderer(rc, rc.getEdgeLabelRenderer(), label, rc.getPickedEdgeState().isPicked(e), e);
    Dimension d = component.getPreferredSize();
    xform.translate(-d.width / 2.0d, -(d.height / 2.0d - parallelOffset));
    g.setTransform(xform);
    g.setColor(Colors.WHITE);
    g.draw(component, rc.getRendererPane(), 0, 0, d.width, d.height, true);
    g.setTransform(old);
}
 
开发者ID:rapidminer,项目名称:rapidminer-studio,代码行数:56,代码来源:TreeModelEdgeLabelRenderer.java

示例10: paintShapeForVertex

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
protected void paintShapeForVertex(RenderContext<V,E> rc, V v, Shape shape) {
    GraphicsDecorator g = rc.getGraphicsContext();
    Paint oldPaint = g.getPaint();
    Paint fillPaint = rc.getVertexFillPaintTransformer().transform(v);
    if(fillPaint != null) {
        g.setPaint(fillPaint);
        g.fill(shape);
        g.setPaint(oldPaint);
    }
    Paint drawPaint = rc.getVertexDrawPaintTransformer().transform(v);
    if(drawPaint != null) {
        g.setPaint(drawPaint);
        Stroke oldStroke = g.getStroke();
        Stroke stroke = rc.getVertexStrokeTransformer().transform(v);
        if(stroke != null) {
            g.setStroke(stroke);
        }
        g.draw(shape);
        g.setPaint(oldPaint);
        g.setStroke(oldStroke);
    }
    
    // leaf: draw frequency colors
    if (graphCreator.isLeaf((String)v)) {
        Tree tree = graphCreator.getTree((String)v);
        Map<String,Integer> countMap = tree.getCounterMap();
        int numberOfLabels = countMap.size();
        int frequencySum = tree.getFrequencySum();
        
        double height = tree.getFrequencySum() / (double)maxLeafSize * (FREQUENCY_BAR_MAX_HEIGHT - FREQUENCY_BAR_MIN_HEIGHT) + FREQUENCY_BAR_MIN_HEIGHT;
        double width = shape.getBounds().getWidth() - 2 * FREQUENCY_BAR_OFFSET_X - 1;
        double xPos = shape.getBounds().getX() + FREQUENCY_BAR_OFFSET_X;
        double yPos = shape.getBounds().getY() + shape.getBounds().getHeight() - FREQUENCY_BAR_OFFSET_Y - height;
        ColorProvider colorProvider = new ColorProvider();
        for (String labelValue: countMap.keySet()) {
        	int count = tree.getCount(labelValue);
            double currentWidth = ((double)count / (double)frequencySum) * width;
            Rectangle2D.Double frequencyRect = 
                new Rectangle2D.Double(xPos, 
                                       yPos,
                                       currentWidth,
                                       height);
            int counter = model.getTrainingHeader().getAttributes().getLabel().getMapping().mapString(labelValue);
            g.setColor(colorProvider.getPointColor((double) counter / (double) (numberOfLabels - 1)));
            g.fill(frequencyRect);
            g.setColor(Color.BLACK);
            xPos += currentWidth;
        }
        g.setColor(Color.BLACK);
        g.draw(new Rectangle2D.Double(shape.getBounds().getX() + FREQUENCY_BAR_OFFSET_X, yPos, width, height));

        g.setPaint(oldPaint);
    }
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:55,代码来源:TreeModelNodeRenderer.java


注:本文中的edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator.setColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。