use of org.cytoscape.ding.impl.cyannotator.annotations.DingAnnotation in project cytoscape-impl by cytoscape.
the class ArbitraryGraphicsCanvas method drawCanvas.
public void drawCanvas(VolatileImage image, double xMin, double yMin, double xCenter, double yCenter, double scaleFactor) {
// get image graphics
final Graphics2D image2D = image.createGraphics();
// System.out.println("drawCanvas: new scaleFactor = "+scaleFactor+", xCenter = "+xCenter+", yCenter = "+yCenter);
if (m_isOpaque)
clearImage(image2D);
double xOffset = ((image.getWidth() / 2) / scaleFactor - xCenter);
double yOffset = ((image.getHeight() / 2) / scaleFactor - yCenter);
// get list of child components
Component[] components = getComponents();
// Since we're doing this because we're doing the draw on our own
zSort(components);
// no components, outta here
if (components.length == 0)
return;
// iterate through the components
for (Component c : components) {
// get position of this component in network coordinates
Point position = m_componentToPointMap.get(c);
if (position == null)
continue;
// int xOrig = position.x;
// int yOrig = position.y;
final double[] nodeCanvasCoordinates = new double[2];
nodeCanvasCoordinates[0] = position.getX() + xOffset;
nodeCanvasCoordinates[1] = position.getY() + yOffset;
// If we're painting an annotation, set the zoom
if (c instanceof DingAnnotation) {
DingAnnotation a = (DingAnnotation) c;
a.drawAnnotation(image2D, position.getX() + xOffset, position.getY() + yOffset, scaleFactor);
}
}
// System.out.println("drawCanvas: done");
}
use of org.cytoscape.ding.impl.cyannotator.annotations.DingAnnotation in project cytoscape-impl by cytoscape.
the class CyAnnotator method getAnnotationAt.
public DingAnnotation getAnnotationAt(Point2D position) {
DingAnnotation a = getComponentAt(foreGroundCanvas, (int) position.getX(), (int) position.getY());
if (a != null) {
while (a.getGroupParent() != null) {
a = (DingAnnotation) a.getGroupParent();
}
return a;
}
a = getComponentAt(backGroundCanvas, (int) position.getX(), (int) position.getY());
if (a != null) {
while (a.getGroupParent() != null) a = (DingAnnotation) a.getGroupParent();
}
return a;
}
use of org.cytoscape.ding.impl.cyannotator.annotations.DingAnnotation in project cytoscape-impl by cytoscape.
the class CyAnnotator method updateNetworkAttributes.
private void updateNetworkAttributes(CyNetwork network) {
// Convert the annotation to a list
List<Map<String, String>> networkAnnotations = new ArrayList<Map<String, String>>();
for (DingAnnotation annotation : annotationMap.keySet()) {
if (view.getModel().equals(network))
networkAnnotations.add(annotationMap.get(annotation));
}
// Save it in the network attributes
List<String> networkAnnotation = convertAnnotationMap(networkAnnotations);
if (network.getDefaultNetworkTable().getColumn(ANNOTATION_ATTRIBUTE) == null) {
network.getDefaultNetworkTable().createListColumn(ANNOTATION_ATTRIBUTE, String.class, false, Collections.EMPTY_LIST);
}
network.getRow(network, CyNetwork.LOCAL_ATTRS).set(ANNOTATION_ATTRIBUTE, networkAnnotation);
}
use of org.cytoscape.ding.impl.cyannotator.annotations.DingAnnotation in project cytoscape-impl by cytoscape.
the class CyAnnotator method addAnnotations.
public void addAnnotations(Collection<? extends Annotation> annotations) {
for (Annotation annotation : annotations) {
if (annotation instanceof DingAnnotation) {
DingAnnotation dingAnnotation = (DingAnnotation) annotation;
annotationMap.put(dingAnnotation, dingAnnotation.getArgMap());
}
}
updateNetworkAttributes(view.getModel());
}
use of org.cytoscape.ding.impl.cyannotator.annotations.DingAnnotation in project cytoscape-impl by cytoscape.
the class CanvasMouseListener method mouseClicked.
public void mouseClicked(MouseEvent e) {
// Check to see if we're resizing
if (cyAnnotator.getResizeShape() != null) {
cyAnnotator.getResizeShape().contentChanged();
cyAnnotator.resizeShape(null);
return;
}
if (cyAnnotator.getRepositioningArrow() != null) {
cyAnnotator.getRepositioningArrow().contentChanged();
cyAnnotator.positionArrow(null);
return;
}
if (cyAnnotator.getMovingAnnotation() != null) {
cyAnnotator.getMovingAnnotation().contentChanged();
cyAnnotator.moveAnnotation(null);
return;
}
DingAnnotation annotation = cyAnnotator.getAnnotationAt(new Point(e.getX(), e.getY()));
if (annotation == null) {
// cyAnnotator.clearSelectedAnnotations();
if (!e.isConsumed()) {
networkCanvas.processMouseEvent(e);
e.consume();
}
return;
}
/*
* It seems to be a little confusing to have double-click
* selection on annotations.
*/
/*
if(e.getClickCount()==2 && !e.isConsumed()) {
e.consume();
//We have doubled clicked on an Annotation
if (annotation.isSelected()) {
annotation.setSelected(false);
} else {
//This preVZoom value will help in resizing the selected Annotations
// double prevZoom=networkCanvas.getScaleFactor();
// annotation.setSpecificZoom(prevZoom);
annotation.setSelected(true);
//We request focus in this window, so that we can move these selected Annotations around using arrow keys
annotation.getCanvas().requestFocusInWindow();
}
//Repaint the canvas
annotation.getCanvas().repaint();
}
*/
}
Aggregations