本文整理汇总了Java中edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator.fill方法的典型用法代码示例。如果您正苦于以下问题:Java GraphicsDecorator.fill方法的具体用法?Java GraphicsDecorator.fill怎么用?Java GraphicsDecorator.fill使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator
的用法示例。
在下文中一共展示了GraphicsDecorator.fill方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintVertex
import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
@Override public void paintVertex(RenderContext<String, String> rc,
Layout<String, String> layout, String vertex) {
GraphicsDecorator graphicsContext = rc.getGraphicsContext();
Point2D center = layout.transform(vertex);
Shape shape = null;
Color color = null;
if(vertex.equals("Square")) {
shape = new Rectangle((int)center.getX()-10, (int)center.getY()-10, 20, 20);
color = new Color(127, 127, 0);
} else if(vertex.equals("Rectangle")) {
shape = new Rectangle((int)center.getX()-10, (int)center.getY()-20, 20, 40);
color = new Color(127, 0, 127);
} else if(vertex.equals("Circle")) {
shape = new Ellipse2D.Double(center.getX()-10, center.getY()-10, 20, 20);
color = new Color(0, 127, 127);
}
graphicsContext.setPaint(color);
graphicsContext.fill(shape);
}
示例2: 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);
}
}
示例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);
}
示例4: 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();
Rectangle r = shape.getBounds();
float y2 = (float)r.getMaxY();
if(cyclic) {
y2 = (float)(r.getMinY()+r.getHeight()/2);
}
Paint fillPaint = null;
if(pickedState != null && pickedState.isPicked(v)) {
fillPaint = new GradientPaint((float)r.getMinX(), (float)r.getMinY(), pickedColorOne,
(float)r.getMinX(), y2, pickedColorTwo, cyclic);
} else {
fillPaint = new GradientPaint((float)r.getMinX(), (float)r.getMinY(), colorOne,
(float)r.getMinX(), y2, colorTwo, cyclic);
}
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);
}
示例5: 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);
}
}
示例6: 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);
}
}
}
示例7: paintEdge
import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void paintEdge(RenderContext<V, E> rc, Layout<V, E> layout, E e) {
GraphicsDecorator g = rc.getGraphicsContext();
Graph<V, E> graph = layout.getGraph();
if (!rc.getEdgeIncludePredicate().evaluate(Context.<Graph<V, E>, E>getInstance(graph, e))) {
return;
}
Pair<V> endpoints = graph.getEndpoints(e);
if (!rc.getVertexIncludePredicate().evaluate(Context.<Graph<V, E>, V>getInstance(graph, endpoints.getFirst()))
|| !rc.getVertexIncludePredicate()
.evaluate(Context.<Graph<V, E>, V>getInstance(graph, endpoints.getSecond()))) {
return;
}
Point2D p1 = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, layout.transform(endpoints.getFirst()));
Point2D p2 = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, layout.transform(endpoints.getSecond()));
Shape edgeShape = rc.getEdgeShapeTransformer().transform(Context.<Graph<V, E>, E>getInstance(graph, e));
Rectangle deviceRectangle = new Rectangle(rc.getScreenDevice().getSize());
AffineTransform edgeTransform = AffineTransform.getTranslateInstance(p1.getX(), p1.getY());
if (endpoints.getFirst().equals(endpoints.getSecond())) {
Rectangle2D bounds = rc.getVertexShapeTransformer().transform(endpoints.getFirst()).getBounds2D();
edgeTransform.scale(bounds.getWidth(), bounds.getHeight());
edgeTransform.translate(0, -edgeShape.getBounds2D().getWidth() / 2);
} else {
double dx = p2.getX() - p1.getX();
double dy = p2.getY() - p1.getY();
edgeTransform.rotate(Math.atan2(dy, dx));
edgeTransform.scale(Math.sqrt(dx * dx + dy * dy), 1.0);
}
edgeShape = edgeTransform.createTransformedShape(edgeShape);
if (rc.getMultiLayerTransformer().getTransformer(Layer.VIEW).transform(edgeShape).intersects(deviceRectangle)) {
Paint oldPaint = g.getPaint();
Stroke oldStroke = g.getStroke();
BasicStroke stroke = (BasicStroke) rc.getEdgeStrokeTransformer().transform(e);
Paint drawPaint = rc.getEdgeDrawPaintTransformer().transform(e);
if (drawPaint != null) {
g.setStroke(new BasicStroke(stroke.getLineWidth() + 4, stroke.getEndCap(), stroke.getLineJoin(),
stroke.getMiterLimit(), stroke.getDashArray(), stroke.getDashPhase()));
g.setPaint(drawPaint);
g.draw(edgeShape);
}
g.setStroke(stroke);
g.setPaint(rc.getEdgeFillPaintTransformer().transform(e));
g.draw(edgeShape);
if (rc.getEdgeArrowPredicate().evaluate(Context.<Graph<V, E>, E>getInstance(graph, e))) {
AffineTransform destVertexTransform = AffineTransform.getTranslateInstance(p2.getX(), p2.getY());
Shape destVertexShape = destVertexTransform.createTransformedShape(
rc.getVertexShapeTransformer().transform(graph.getEndpoints(e).getSecond()));
if (rc.getMultiLayerTransformer().getTransformer(Layer.VIEW).transform(destVertexShape)
.intersects(deviceRectangle)) {
AffineTransform arrowTransform = edgeArrowRenderingSupport.getArrowTransform(rc, edgeShape,
destVertexShape);
Shape arrow = arrowTransform.createTransformedShape(
rc.getEdgeArrowTransformer().transform(Context.<Graph<V, E>, E>getInstance(graph, e)));
g.setStroke(rc.getEdgeArrowStrokeTransformer().transform(e));
g.setPaint(rc.getArrowFillPaintTransformer().transform(e));
g.fill(arrow);
g.setPaint(rc.getArrowDrawPaintTransformer().transform(e));
g.draw(arrow);
}
}
g.setPaint(oldPaint);
g.setStroke(oldStroke);
}
}
示例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 (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);
}
}