Are the sources for the giny and the phoebe library (.jars) available
somewhere? I tried
http://csbi.sourceforge.net/
but the sources checked out from that cvs repository
(anon...@csbi.cvs.sourceforge.net:/cvsroot/csbi/ , module giny)
doesn't build.
(one compile error for example:
phoebe.util.P3DNode is not abstract and does not override abstract
method getNodeLabelAnchor() in giny.view.NodeView )
I'm asking this because I'm trying to make use custom Stroke-s in
custom LineTypes for rendering edges. If I use a java.awt.BasicStroke
with a custom width setting, it works, but if I use a custom class
that implements java.awt.Stroke (but does not subclass BasicStroke)
then nothing happens (i.e. my custom Stroke gets ignored, and the edge
is drawn with the default style.) Any idea what might cause such a
thing?
Thanks in advance,
Abel Daniel
> As for your question about strokes, I wonder if you're trying to set the
> stroke in the proper place? Unless you're using an old (i.e. version 2.2)
> version of Cytoscape, we no longer use phoebe, we have our own rendering
> engine. Naturally, our rendering engine (available in corelibs) doesn't
> provide a method to access the line stroke, but if you wanted to hack the
> code, it would be possible. Let me know and I can provide further details.
My original plan was to create a custom LineType.
cytoscape.visual.LineType is basically simply a java.awt.Stroke and a
String name. I made a cytoscape.visual.mappings.ObjectMapping subclass
that creates instances of this custom
LineType. The problem is that the backend code can only handle
BasicStroke subclasses.
ding.view.DEdgeView.setStroke() explicitly ignores non-BasicStroke
subclass Strokes. Basically
the BasicStroke instance is only used to store the parameters of the
edge (width and dashArray)
_not_ for doing the drawing. This looks quite stupid to me: First a
Stroke is created (when
initializing LineType) that is passed to the framework. At one point
the framework extracts
some parameters from it, then recreates basically the same thing (in
render.immed.GraphGraphics).
Shouldn't this be refactored so that the same Stroke that is passed in
is used for the painting?
Is there any good reason to leave it the way it is?
For example, in GraphGraphics there is the following comment:
// Unfortunately, BasicStroke is not mutable. So we have to
construct
// lots of new strokes if they constantly change.
But that wouldn't be needed if the Strokes weren't recreated! If the
LineType's Stroke would be
used, it wouldn't have to be created all the time. (If only the
Strokes defined in LineType are
used, then _all_ edges would be drawn with the _same_ Stroke. No
unnecessary object creation
_at_ _all_.)
> I'm not certain why we save the BasicStroke parameters rather than saving
> BasicStrokes, but I'm guessing this is because BasicStroke isn't mutable.
> The motivation for saving parameters at all has to do with the level of
> graph detail.
Oh. yes, that makes sense. However, there is a fixed number of detail
levels,
so wouldn't "pushing detail definition up the api stack a bit" be a
better idea?.
I.e. make LineType have lowDetailStroke, highDetailStroke etc.
members. and
use the appropriate one for drawing. Having different detail levels
doesn't rule out
using the supplied Stroke object for the actual drawing.
Such a solution would be much more natural, and much easier to extend
with different line styles.
> So, there are a few good reasons to leave things as they are. That said,
> we've been toying with the idea of expanding the types of lines allowed.
> We're currently thinking that this would primarily mean different dash
> lengths and styles.
>
> Can you explain the type of effect you're trying achieve?
The user request I'm trying to implement is to show multiplicity of
edges by drawing parallel edges.
An A->B edge wich has a 'multiplicity' attribute with the value 3, for
example, would be shown as
three lines between those nodes. I am trying to do this by using a
Stroke that draws three lines
instead of one.
(I think implementing this by using a custom Stroke is the easiest
thing to do. I could create two
'fake edges' but that would foul other things up. I could hack in some
sort of multiplicity into
the backend code, but that would be ugly. For some examples of what
can be done with custom Stroke
classes, see http://www.java2s.com/Code/Java/2D-Graphics-GUI/CustomStrokes.htm
the DoubleStroke
is sort of what I am planning to do.)
--
Abel Daniel
Oh. yes, that makes sense. However, there is a fixed number of detail
levels,
so wouldn't "pushing detail definition up the api stack a bit" be a
better idea?.
The user request I'm trying to implement is to show multiplicity of
edges by drawing parallel edges.
An A->B edge wich has a 'multiplicity' attribute with the value 3, for
example, would be shown as
three lines between those nodes. I am trying to do this by using a
Stroke that draws three lines
instead of one.
(I think implementing this by using a custom Stroke is the easiest
thing to do. I could create two
'fake edges' but that would foul other things up. I could hack in some
sort of multiplicity into
the backend code, but that would be ugly. For some examples of what
can be done with custom Stroke
classes, see http://www.java2s.com/Code/Java/2D-Graphics-GUI/CustomStrokes.htm
the DoubleStroke
is sort of what I am planning to do.)
> That said, if you were interested in writing a patch that would allow
> EdgeDetails to store edge parameters (i.e. dash length, width, etc.) as a
> mutable extension of BasicStroke (not just a Stroke), refactor everything
> else, and thus (hopefully) allow for customized strokes to be set at the
> cytoscape level, then I'd be happy to advise. However, this is a big change
> that will touch some really important parts of Cytoscape's core, which means
> there would be a high standard for making changes.
I implemented the changes I suggested. I think that even if easy
implementation of custom strokes is not an issue, not recreating
Strokes all the time makes the code cleaner and easier to understand.
The zipped patch is at http://abeld.web.elte.hu/use_stroke_patch.zip
The contents of the zip file:
cytoscape_diff: output of 'svn diff' (i.e. diff against
http://chianti.ucsd.edu/svn/cytoscape/trunk, r9703)
corelibs_diff: output of 'svn diff' (i.e. diff against
http://chianti.ucsd.edu/svn/corelibs/trunk, r9703)
double_1.jpg: file to be placed in cytoscape/src/cytoscape/visual/ui/
images/
curved_edges.xgmml: testcase that has one edge set to DOUBLE_1
LineType
To test, simply apply the diffs, copy double_1.jpg in the right place,
compile, start cytoscape then load curved_edges.xgmml. One of the
edges should be a double-edge. The ends of that double edge is ugly,
but that is a limitation of DoubleStroke, which can be fixed. Note
that selecting the double edge is quite natural. (For selection
purposes,
it is simply a really thick (single) edge.)
Summary of changes:
- Add a thickness member to LineType.
(this is needed because the low-level code uses edge thickness to
calculate some things, for example arrow sizes (as far as I could
tell), and for handling selection)
- in ding and render.stateful and render.immed: use the Stroke
supplied by the LineType, don't extract width and dash parameters
from it.
- To make demo work: add a DOUBLE_1 LineType. This is only for showing
that custom strokes work, an improved implementation would be needed
(for triple-edges, and for better handling of edge ends, for
example).
Note that this patch is not a "make cytoscape have multiply stroked
edges" kind of patch, but a "refactor cytoscape innards to not mangle
the Stroke object of LineType", and the inclusion of the DoubleStroke
part (which means most of the changes in cytoscape_diff) is simply to
show that the thing works.
I didn't fix the javadoc comments, and I assume reindenting would be
needed, too (if the patch is accepted.)
If accepted, graph import / export might need to be fixed (for
example, XGMMLWriter casts to BasicStroke, too.)
In GraphGraphics.drawEdgeFull(), I removed some tests based on
dashLength. As far as I understood the code, those tests where needed
to handle dashed edges, but I didn't see any changes after removing
them. What where those doing?
In one or two cases the decision to draw an edge dashed was based on
the level-of-detail setting. These might be changed to drawing with
GraphGraphics.drawEdgeLow().
I would be interested in your opinion about the patch.
--
Abel Daniel
cytoscape_diff: output of 'svn diff' ( i.e. diff against