Author: scooter
Date: 2010-08-11 17:17:53 -0700 (Wed, 11 Aug 2010)
New Revision: 21343
Modified:
corelibs/trunk/ding/src/main/java/ding/view/ArbitraryGraphicsCanvas.java
corelibs/trunk/ding/src/main/java/ding/view/DGraphView.java
corelibs/trunk/ding/src/main/java/ding/view/InnerCanvas.java
Log:
Changes for CyAnnotator support
Modified:
corelibs/trunk/ding/src/main/java/ding/view/ArbitraryGraphicsCanvas.java
===================================================================
--- corelibs/trunk/ding/src/main/java/ding/view/ArbitraryGraphicsCanvas.java
2010-08-12 00:09:31 UTC (rev 21342)
+++ corelibs/trunk/ding/src/main/java/ding/view/ArbitraryGraphicsCanvas.java
2010-08-12 00:17:53 UTC (rev 21343)
@@ -63,7 +63,7 @@
/**
* Testing boolean to quickly turn on/off anchor nodes.
*/
- private static final boolean USE_REPOSITION_CODE = false;
+ private static final boolean USE_REPOSITION_CODE = true;
/**
* Our reference to the GraphPerspective our view belongs to
@@ -82,7 +82,7 @@
/*
* Map of component(s) to hidden node(s)
- */
+ */
private final Map<Component, Node> m_componentToNodeMap;
/**
@@ -111,6 +111,7 @@
/**
* Our implementation of add
*/
+ @Override
public Component add(Component component) {
if (USE_REPOSITION_CODE) {
// create an "anchor node"
@@ -123,7 +124,7 @@
final NodeView nodeView =
m_dGraphView.getNodeView(node);
final double[] nodeCanvasCoordinates = new double[2];
nodeCanvasCoordinates[0] = component.getX();
- nodeCanvasCoordinates[1] = component.getY();
+ nodeCanvasCoordinates[1] = component.getY();
m_dGraphView.xformComponentToNodeCoords(nodeCanvasCoordinates);
nodeView.setXPosition(nodeCanvasCoordinates[0]);
nodeView.setYPosition(nodeCanvasCoordinates[1]);
@@ -141,7 +142,7 @@
// do our stuff
return super.add(component);
}
-
+
/**
* Our implementation of ViewportChangeListener.
*/
@@ -153,12 +154,27 @@
}
}
+ public void modifyComponentLocation(int x,int y, int componentNum){
+ if(USE_REPOSITION_CODE){
+ final NodeView nodeView =
m_dGraphView.getNodeView(m_componentToNodeMap.get(this.getComponent(componentNum)));
+ final double[] nodeCanvasCoordinates = new double[2];
+
+ nodeCanvasCoordinates[0] = x;
+ nodeCanvasCoordinates[1] = y;
+
+
m_dGraphView.xformComponentToNodeCoords(nodeCanvasCoordinates);
+
+ nodeView.setXPosition(nodeCanvasCoordinates[0]);
+ nodeView.setYPosition(nodeCanvasCoordinates[1]);
+ }
+ }
+
/**
* Our implementation of JComponent setBounds.
*/
public void setBounds(int x, int y, int width, int height) {
super.setBounds(x, y, width, height);
-
+
// our bounds have changed, create a new image with new size
if ((width > 1) && (height > 1)) {
// create the buffered image
@@ -187,14 +203,35 @@
clearImage(image2D);
// now paint children
- if (m_isVisible)
- paintChildren(image2D);
-
+ if (m_isVisible){
+ int num=this.getComponentCount();
+ for(int i=0;i<num;i++){
+ this.getComponent(i).paint(image2D);
+ }
+ }
+ image2D.dispose();
// render image
graphics.drawImage(m_img, 0, 0, null);
}
+
}
+
+ @Override
+ public Component getComponentAt(int x, int y) {
+
+ int n=getComponentCount();
+
+ for(int i=0;i<n;i++){
+ Component
c=this.getComponent(i).getComponentAt(x, y);
+
+ if(c!=null)
+ return c;
+ }
+ return null;
+ }
+
+
/**
* Invoke this method to print the component.
*
Modified: corelibs/trunk/ding/src/main/java/ding/view/DGraphView.java
===================================================================
--- corelibs/trunk/ding/src/main/java/ding/view/DGraphView.java 2010-08-12
00:09:31 UTC (rev 21342)
+++ corelibs/trunk/ding/src/main/java/ding/view/DGraphView.java 2010-08-12
00:17:53 UTC (rev 21343)
@@ -364,6 +364,14 @@
return m_perspective;
}
+ public Object getLock(){
+ return m_lock;
+ }
+
+ public void setViewportChanged(boolean val){
+ m_viewportChanged=val;
+ }
+
/**
* Whether node selection is enabled.
*
@@ -1044,7 +1052,7 @@
//System.out.println("**************** DGraph Redraw Called
***************** " + this.getGraphPerspective());
//Thread.dumpStack();
//System.out.println("**************** DGraph Redraw Finished
*****************\n\n" );
-
+
m_networkCanvas.repaint();
}
Modified: corelibs/trunk/ding/src/main/java/ding/view/InnerCanvas.java
===================================================================
--- corelibs/trunk/ding/src/main/java/ding/view/InnerCanvas.java
2010-08-12 00:09:31 UTC (rev 21342)
+++ corelibs/trunk/ding/src/main/java/ding/view/InnerCanvas.java
2010-08-12 00:17:53 UTC (rev 21343)
@@ -98,9 +98,7 @@
final IntStack m_stack = new IntStack();
final IntStack m_stack2 = new IntStack();
final Object m_lock;
-
DGraphView m_view;
-
final GraphLOD[] m_lod = new GraphLOD[1];
final IntHash m_hash;
GraphGraphics m_grafx;
@@ -115,6 +113,7 @@
private boolean NodeMovement = true;
+
/**
* String used to compare against os.name System property -
* to determine if we are running on Windows platform.
@@ -126,22 +125,19 @@
// for turning selection rectangle on and off
private boolean selecting = true;
-
public Vector listeners = new Vector();
private Vector transferComponents = new Vector();
-
/**
* Listeners for node right-click menu
*/
public Vector nodeContextMenuListeners = new Vector();
-
+
/**
* Listeners for edge right-click menu.
*/
public Vector edgeContextMenuListeners = new Vector();
-
InnerCanvas(Object lock, DGraphView view) {
super();
m_lock = lock;
@@ -164,7 +160,14 @@
DnDConstants.ACTION_COPY, // actions
this); // DropTargetListener
}
+
+ public double getScaleFactor(){
+ return m_scaleFactor;
+ }
+ public void setScaleFactor(double val){
+ m_scaleFactor=val;
+ }
/**
* DOCUMENT ME!
*
@@ -256,15 +259,15 @@
}
/**
- * This print method will be used by Image Export functions.
+ * DOCUMENT ME!
*
* @param g Usually Graphics2D object for drawing network view as image.
- *
*/
- public void print(Graphics g) {
+ public void print(Graphics g) {
renderGraph(new GraphGraphics(
new ImageImposter(g, getWidth(), getHeight()),
false),
/* setLastRenderDetail = */ false,
m_view.m_printLOD);
+ // g.drawImage(img, 0, 0, null);
}
/**
@@ -1180,6 +1183,19 @@
protected synchronized void
processPhoebeCanvasDropEvent(PhoebeCanvasDropEvent event) {
Enumeration e = listeners.elements();
+ // // AJK: 12/08/06 oy, what a hack. try to send
transferable to transferhandler
+ // // of cytoscapeDesktopPane
+ // Transferable t = event.getTransferable();
+ // TransferHandler th =
Cytoscape.getDesktop().getNetworkViewManager().
+ // getDesktopPane().getTransferHandler();
+ // if (th != null)
+ // {
+ //
th.importData(Cytoscape.getDesktop().getNetworkViewManager().
+ // getDesktopPane(), t);
+ // }
+ // // AJK: 12/08/06 END
+
+ // // AJK: 01/14/07 oy, what a hack. try to send
transferable to transferhandler
Transferable t = event.getTransferable();
TransferHandler th;
JComponent jComp;
@@ -1363,7 +1379,6 @@
public boolean isSelecting() {
return selecting;
}
-
/**
* Called to get the tranform matrix used by the inner canvas
@@ -1417,7 +1432,7 @@
private void renderGraph(GraphGraphics graphics, final boolean
setLastRenderDetail, final GraphLOD lod) {
// Set color alpha based on opacity setting
final int alpha = (m_isOpaque) ? 255 : 0;
-
+
final Color backgroundColor = new
Color(m_backgroundColor.getRed(), m_backgroundColor.getGreen(),
m_backgroundColor.getBlue(), alpha);
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.