本文整理汇总了Java中edu.uci.ics.jung.visualization.transform.shape.ShapeTransformer类的典型用法代码示例。如果您正苦于以下问题:Java ShapeTransformer类的具体用法?Java ShapeTransformer怎么用?Java ShapeTransformer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ShapeTransformer类属于edu.uci.ics.jung.visualization.transform.shape包,在下文中一共展示了ShapeTransformer类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paint
import edu.uci.ics.jung.visualization.transform.shape.ShapeTransformer; //导入依赖的package包/类
@Override
public void paint(Graphics g) {
ShapeTransformer masterViewTransformer = master.getRenderContext()
.getMultiLayerTransformer().getTransformer(Layer.VIEW);
ShapeTransformer masterLayoutTransformer = master
.getRenderContext().getMultiLayerTransformer()
.getTransformer(Layer.LAYOUT);
ShapeTransformer vvLayoutTransformer = vv.getRenderContext()
.getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
// changed: bounds without offset
Shape lens = new Rectangle(new Point(), master.getSize());
lens = masterViewTransformer.inverseTransform(lens);
lens = masterLayoutTransformer.inverseTransform(lens);
lens = vvLayoutTransformer.transform(lens);
Graphics2D g2d = (Graphics2D) g;
Color old = g.getColor();
Color lensColor = master.getBackground();
vv.setBackground(lensColor.darker());
g.setColor(lensColor);
g2d.fill(lens);
g.setColor(Color.gray);
g2d.draw(lens);
g.setColor(old);
}
示例2: paint
import edu.uci.ics.jung.visualization.transform.shape.ShapeTransformer; //导入依赖的package包/类
@Override
public void paint(Graphics g) {
ShapeTransformer masterViewTransformer = master.getRenderContext()
.getMultiLayerTransformer().getTransformer(Layer.VIEW);
ShapeTransformer masterLayoutTransformer = master
.getRenderContext().getMultiLayerTransformer()
.getTransformer(Layer.LAYOUT);
ShapeTransformer vvLayoutTransformer = vv.getRenderContext()
.getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
// changed: bounds without offset
Shape lens = new Rectangle(new Point(), master.getSize());
lens = masterViewTransformer.inverseTransform(lens);
lens = masterLayoutTransformer.inverseTransform(lens);
lens = vvLayoutTransformer.transform(lens);
Graphics2D g2d = (Graphics2D) g;
Color old = g.getColor();
Color lensColor = master.getBackground();
vv.setBackground(lensColor.darker());
g.setColor(lensColor);
g2d.fill(lens);
g.setColor(Color.gray);
g2d.draw(lens);
g.setColor(old);
}
示例3: paint
import edu.uci.ics.jung.visualization.transform.shape.ShapeTransformer; //导入依赖的package包/类
public void paint(Graphics g) {
ShapeTransformer masterViewTransformer =
master.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW);
ShapeTransformer masterLayoutTransformer = master.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
ShapeTransformer vvLayoutTransformer = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
Shape lens = master.getBounds();
lens = masterViewTransformer.inverseTransform(lens);
lens = masterLayoutTransformer.inverseTransform(lens);
lens = vvLayoutTransformer.transform(lens);
Graphics2D g2d = (Graphics2D)g;
Color old = g.getColor();
Color lensColor = master.getBackground();
vv.setBackground(lensColor.darker());
g.setColor(lensColor);
g2d.fill(lens);
g.setColor(Color.gray);
g2d.draw(lens);
g.setColor(old);
}
示例4: paint
import edu.uci.ics.jung.visualization.transform.shape.ShapeTransformer; //导入依赖的package包/类
public void paint(Graphics g) {
ShapeTransformer masterViewTransformer = master.getViewTransformer();
ShapeTransformer masterLayoutTransformer = master.getLayoutTransformer();
ShapeTransformer vvLayoutTransformer = vv.getLayoutTransformer();
Shape lens = master.getBounds();
lens = masterViewTransformer.inverseTransform(lens);
lens = masterLayoutTransformer.inverseTransform(lens);
lens = vvLayoutTransformer.transform(lens);
Graphics2D g2d = (Graphics2D)g;
Color old = g.getColor();
Color lensColor = master.getBackground();
vv.setBackground(lensColor.darker());
g.setColor(lensColor);
g2d.fill(lens);
g.setColor(Color.gray);
g2d.draw(lens);
g.setColor(old);
}
示例5: labelVertex
import edu.uci.ics.jung.visualization.transform.shape.ShapeTransformer; //导入依赖的package包/类
/**
* Labels the specified vertex with the specified label. Uses the font specified by this
* instance's <code>VertexFontFunction</code>. (If the font is unspecified, the existing font
* for the graphics context is used.) If vertex label centering is active, the label is centered
* on the position of the vertex; otherwise the label is offset slightly.
*/
@Override
public void labelVertex(RenderContext<V, E> rc, Layout<V, E> layout, V v, String label) {
Graph<V, E> graph = layout.getGraph();
if (rc.getVertexIncludePredicate().evaluate(Context.<Graph<V, E>, V> getInstance(graph, v)) == false) {
return;
}
Point2D pt = layout.transform(v);
pt = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, pt);
float x = (float) pt.getX();
float y = (float) pt.getY();
Component component = prepareRenderer(rc, rc.getVertexLabelRenderer(), label, rc.getPickedVertexState().isPicked(v),
v);
GraphicsDecorator g = rc.getGraphicsContext();
Dimension d = component.getPreferredSize();
AffineTransform xform = AffineTransform.getTranslateInstance(x, y);
Shape shape = rc.getVertexShapeTransformer().transform(v);
shape = xform.createTransformedShape(shape);
if (rc.getGraphicsContext() instanceof TransformingGraphics) {
BidirectionalTransformer transformer = ((TransformingGraphics) rc.getGraphicsContext()).getTransformer();
if (transformer instanceof ShapeTransformer) {
ShapeTransformer shapeTransformer = (ShapeTransformer) transformer;
shape = shapeTransformer.transform(shape);
}
}
Rectangle2D bounds = shape.getBounds2D();
Point p = null;
if (position == Position.AUTO) {
Dimension vvd = rc.getScreenDevice().getSize();
if (vvd.width == 0 || vvd.height == 0) {
vvd = rc.getScreenDevice().getPreferredSize();
}
p = getAnchorPoint(bounds, d, positioner.getPosition(x, y, vvd));
} else {
p = getAnchorPoint(bounds, d, position);
}
if (graphCreator.isLeaf((String) v)) {
p.setLocation(p.x, p.y + LABEL_OFFSET_Y);
}
g.draw(component, rc.getRendererPane(), p.x, p.y, d.width, d.height, true);
}
示例6: labelVertex
import edu.uci.ics.jung.visualization.transform.shape.ShapeTransformer; //导入依赖的package包/类
/**
* Labels the specified vertex with the specified label. Uses the font specified by this
* instance's <code>VertexFontFunction</code>. (If the font is unspecified, the existing font
* for the graphics context is used.) If vertex label centering is active, the label is centered
* on the position of the vertex; otherwise the label is offset slightly.
*/
@Override
public void labelVertex(RenderContext<V, E> rc, Layout<V, E> layout, V v, String label) {
Graph<V, E> graph = layout.getGraph();
if (rc.getVertexIncludePredicate().evaluate(Context.<Graph<V, E>, V> getInstance(graph, v)) == false) {
return;
}
Point2D pt = layout.transform(v);
pt = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, pt);
float x = (float) pt.getX();
float y = (float) pt.getY();
Component component = prepareRenderer(rc, rc.getVertexLabelRenderer(), label, rc.getPickedVertexState().isPicked(v),
v);
GraphicsDecorator g = rc.getGraphicsContext();
Dimension d = component.getPreferredSize();
AffineTransform xform = AffineTransform.getTranslateInstance(x, y);
Shape shape = rc.getVertexShapeTransformer().transform(v);
shape = xform.createTransformedShape(shape);
if (rc.getGraphicsContext() instanceof TransformingGraphics) {
BidirectionalTransformer transformer = ((TransformingGraphics) rc.getGraphicsContext()).getTransformer();
if (transformer instanceof ShapeTransformer) {
ShapeTransformer shapeTransformer = (ShapeTransformer) transformer;
shape = shapeTransformer.transform(shape);
}
}
Rectangle2D bounds = shape.getBounds2D();
Point p = null;
if (position == Position.AUTO) {
Dimension vvd = rc.getScreenDevice().getSize();
if (vvd.width == 0 || vvd.height == 0) {
vvd = rc.getScreenDevice().getPreferredSize();
}
p = getAnchorPoint(bounds, d, positioner.getPosition(x, y, vvd));
} else {
p = getAnchorPoint(bounds, d, position);
}
if (graphCreator.isLeaf((String) v) && !graphCreator.getModel().getRoot().isNumerical()) {
// shift the label if there is a frequency bar
p.setLocation(p.x, p.y + LEAF_LABEL_OFFSET_Y);
}
g.draw(component, rc.getRendererPane(), p.x, p.y, d.width, d.height, true);
}
示例7: paint
import edu.uci.ics.jung.visualization.transform.shape.ShapeTransformer; //导入依赖的package包/类
public void paint(Graphics g) {
ShapeTransformer masterViewTransformer = master.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW);
ShapeTransformer masterLayoutTransformer = master.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
ShapeTransformer vvLayoutTransformer = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
Rectangle rect = master.getBounds();
GeneralPath path = new GeneralPath();
path.moveTo(rect.x, rect.y);
path.lineTo(rect.width,rect.y);
path.lineTo(rect.width, rect.height);
path.lineTo(rect.x, rect.height);
path.lineTo(rect.x, rect.y);
for(int i=0; i<=rect.width; i+=rect.width/10) {
path.moveTo(rect.x+i, rect.y);
path.lineTo(rect.x+i, rect.height);
}
for(int i=0; i<=rect.height; i+=rect.height/10) {
path.moveTo(rect.x, rect.y+i);
path.lineTo(rect.width, rect.y+i);
}
Shape lens = path;
lens = masterViewTransformer.inverseTransform(lens);
lens = masterLayoutTransformer.inverseTransform(lens);
lens = vvLayoutTransformer.transform(lens);
Graphics2D g2d = (Graphics2D)g;
Color old = g.getColor();
g.setColor(Color.cyan);
g2d.draw(lens);
path = new GeneralPath();
path.moveTo((float)rect.getMinX(), (float)rect.getCenterY());
path.lineTo((float)rect.getMaxX(), (float)rect.getCenterY());
path.moveTo((float)rect.getCenterX(), (float)rect.getMinY());
path.lineTo((float)rect.getCenterX(), (float)rect.getMaxY());
Shape crosshairShape = path;
crosshairShape = masterViewTransformer.inverseTransform(crosshairShape);
crosshairShape = masterLayoutTransformer.inverseTransform(crosshairShape);
crosshairShape = vvLayoutTransformer.transform(crosshairShape);
g.setColor(Color.black);
g2d.setStroke(new BasicStroke(3));
g2d.draw(crosshairShape);
g.setColor(old);
}
示例8: labelVertex
import edu.uci.ics.jung.visualization.transform.shape.ShapeTransformer; //导入依赖的package包/类
/**
* Labels the specified vertex with the specified label.
* Uses the font specified by this instance's
* <code>VertexFontFunction</code>. (If the font is unspecified, the existing
* font for the graphics context is used.) If vertex label centering
* is active, the label is centered on the position of the vertex; otherwise
* the label is offset slightly.
*/
public void labelVertex(RenderContext<V,E> rc, Layout<V,E> layout, V v, String label) {
Graph<V,E> graph = layout.getGraph();
if (rc.getVertexIncludePredicate().evaluate(Context.<Graph<V,E>,V>getInstance(graph,v)) == false) {
return;
}
Point2D pt = layout.transform(v);
pt = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, pt);
float x = (float) pt.getX();
float y = (float) pt.getY();
Component component = prepareRenderer(rc, rc.getVertexLabelRenderer(), label,
rc.getPickedVertexState().isPicked(v), v);
GraphicsDecorator g = rc.getGraphicsContext();
Dimension d = component.getPreferredSize();
AffineTransform xform = AffineTransform.getTranslateInstance(x, y);
Shape shape = rc.getVertexShapeTransformer().transform(v);
shape = xform.createTransformedShape(shape);
if(rc.getGraphicsContext() instanceof TransformingGraphics) {
BidirectionalTransformer transformer = ((TransformingGraphics)rc.getGraphicsContext()).getTransformer();
if(transformer instanceof ShapeTransformer) {
ShapeTransformer shapeTransformer = (ShapeTransformer)transformer;
shape = shapeTransformer.transform(shape);
}
}
Rectangle2D bounds = shape.getBounds2D();
Point p = null;
if(position == Position.AUTO) {
Dimension vvd = rc.getScreenDevice().getSize();
if(vvd.width == 0 || vvd.height == 0) {
vvd = rc.getScreenDevice().getPreferredSize();
}
p = getAnchorPoint(bounds, d, positioner.getPosition(x, y, vvd));
} else {
p = getAnchorPoint(bounds, d, position);
}
g.draw(component, rc.getRendererPane(), p.x, p.y, d.width, d.height, true);
}
示例9: labelVertex
import edu.uci.ics.jung.visualization.transform.shape.ShapeTransformer; //导入依赖的package包/类
/**
* Labels the specified vertex with the specified label.
* Uses the font specified by this instance's
* <code>VertexFontFunction</code>. (If the font is unspecified, the existing
* font for the graphics context is used.) If vertex label centering
* is active, the label is centered on the position of the vertex; otherwise
* the label is offset slightly.
*/
public void labelVertex(RenderContext<V,E> rc, Layout<V,E> layout, V v, String label) {
Graph<V,E> graph = layout.getGraph();
if (rc.getVertexIncludePredicate().evaluate(Context.<Graph<V,E>,V>getInstance(graph,v)) == false) {
return;
}
Point2D pt = layout.transform(v);
pt = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, pt);
float x = (float) pt.getX();
float y = (float) pt.getY();
Component component = prepareRenderer(rc, rc.getVertexLabelRenderer(), label,
rc.getPickedVertexState().isPicked(v), v);
GraphicsDecorator g = rc.getGraphicsContext();
Dimension d = component.getPreferredSize();
AffineTransform xform = AffineTransform.getTranslateInstance(x, y);
Shape shape = rc.getVertexShapeTransformer().transform(v);
shape = xform.createTransformedShape(shape);
if(rc.getGraphicsContext() instanceof TransformingGraphics) {
BidirectionalTransformer transformer = ((TransformingGraphics)rc.getGraphicsContext()).getTransformer();
if(transformer instanceof ShapeTransformer) {
ShapeTransformer shapeTransformer = (ShapeTransformer)transformer;
shape = shapeTransformer.transform(shape);
}
}
Rectangle2D bounds = shape.getBounds2D();
Point p = null;
if(position == Position.AUTO) {
Dimension vvd = rc.getScreenDevice().getSize();
if(vvd.width == 0 || vvd.height == 0) {
vvd = rc.getScreenDevice().getPreferredSize();
}
p = getAnchorPoint(bounds, d, positioner.getPosition(x, y, vvd));
} else {
p = getAnchorPoint(bounds, d, position);
}
if (graphCreator.isLeaf((String)v)) {
p.setLocation(p.x, p.y + LABEL_OFFSET_Y);
}
g.draw(component, rc.getRendererPane(), p.x, p.y, d.width, d.height, true);
}
示例10: paint
import edu.uci.ics.jung.visualization.transform.shape.ShapeTransformer; //导入依赖的package包/类
public void paint(Graphics g) {
ShapeTransformer masterViewTransformer = master.getViewTransformer();
ShapeTransformer masterLayoutTransformer = master.getLayoutTransformer();
ShapeTransformer vvLayoutTransformer = vv.getLayoutTransformer();
Rectangle rect = master.getBounds();
GeneralPath path = new GeneralPath();
path.moveTo(rect.x, rect.y);
path.lineTo(rect.width,rect.y);
path.lineTo(rect.width, rect.height);
path.lineTo(rect.x, rect.height);
path.lineTo(rect.x, rect.y);
for(int i=0; i<=rect.width; i+=rect.width/10) {
path.moveTo(rect.x+i, rect.y);
path.lineTo(rect.x+i, rect.height);
}
for(int i=0; i<=rect.height; i+=rect.height/10) {
path.moveTo(rect.x, rect.y+i);
path.lineTo(rect.width, rect.y+i);
}
Shape lens = path;
lens = masterViewTransformer.inverseTransform(lens);
lens = masterLayoutTransformer.inverseTransform(lens);
lens = vvLayoutTransformer.transform(lens);
Graphics2D g2d = (Graphics2D)g;
Color old = g.getColor();
g.setColor(Color.cyan);
g2d.draw(lens);
path = new GeneralPath();
path.moveTo((float)rect.getMinX(), (float)rect.getCenterY());
path.lineTo((float)rect.getMaxX(), (float)rect.getCenterY());
path.moveTo((float)rect.getCenterX(), (float)rect.getMinY());
path.lineTo((float)rect.getCenterX(), (float)rect.getMaxY());
Shape crosshairShape = path;
crosshairShape = masterViewTransformer.inverseTransform(crosshairShape);
crosshairShape = masterLayoutTransformer.inverseTransform(crosshairShape);
crosshairShape = vvLayoutTransformer.transform(crosshairShape);
g.setColor(Color.black);
g2d.setStroke(new BasicStroke(3));
g2d.draw(crosshairShape);
g.setColor(old);
}