public ViewGrid(VisualizationViewer vv, VisualizationViewer master) {
this.vv = vv;
this.master = master;
}
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);