Skip to content

Commit 435cb63

Browse files
committed
Update gephi and platform
Adapt preview examples and add new example to demonstrate default renderer extension Update README
1 parent b38b8a3 commit 435cb63

File tree

723 files changed

+1420
-903
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

723 files changed

+1420
-903
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1+
OpenIDE-Module-Display-Category=Plugin
2+
OpenIDE-Module-Long-Description=\
3+
Data laboratory plugin examples:\n<ul>\n<li><b>Interactive sparkline:</b> Table cell action that shows an interactive sparkline of a number list or dynamic number.\
4+
</li>\n<li><b>Convert column to dynamic:</b> Column action that replaces a column with its dynamic equivalent with a defined interval.\
5+
</li>\n<li><b>Invert row selection:</b> General action (plugin) that inverts the current table row selection.\
6+
</li>\n<li><b>Equal values merge strategy:</b> Column merge strategy that creates a new boolean column with values indicating if the two given columns have the same value.\
7+
</li>\n<li><b>Set node(s) color:</b> Nodes action that edits the color of one or more nodes</li>\n</ul>
18
OpenIDE-Module-Name=DataLaboratoryPluginExample
9+
OpenIDE-Module-Short-Description=Data laboratory plugins examples

DataLaboratoryPluginExample/src/org/gephi/plugins/example/datalab/cell/InteractiveSparkline.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Development and Distribution License("CDDL") (collectively, the
6262
import org.openide.util.NbBundle;
6363

6464
/**
65-
* AttributeValueManipulator (table cell) that shows an interactive sparkline of a list number or dynamic number.
65+
* AttributeValueManipulator (table cell) that shows an interactive sparkline of a number list or dynamic number.
6666
*
6767
* @author Eduardo Ramos <eduramiba@gmail.com>
6868
*/

DataLaboratoryPluginExample/src/org/gephi/plugins/example/datalab/column/ConvertColumnToDynamic.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Development and Distribution License("CDDL") (collectively, the
5757
import org.openide.util.lookup.ServiceProvider;
5858

5959
/**
60-
* AttributeColumnsManipulator that replaces a column with its dynamic equivalent in a default interval.
60+
* AttributeColumnsManipulator that replaces a column with its dynamic equivalent with a defined interval.
6161
*
6262
* @author Eduardo Ramos<eduramiba@gmail.com>
6363
*/
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
build.xml.data.CRC32=2ae927de
1+
build.xml.data.CRC32=2c24e0d5
22
build.xml.script.CRC32=e6b22ef7
3-
build.xml.stylesheet.CRC32=a56c6a5b@1.46.2
3+
build.xml.stylesheet.CRC32=a56c6a5b@2.47.2
44
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
55
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6-
nbproject/build-impl.xml.data.CRC32=2ae927de
6+
nbproject/build-impl.xml.data.CRC32=2c24e0d5
77
nbproject/build-impl.xml.script.CRC32=b1e439e6
8-
nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.46.2
8+
nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.47.2

PreviewPluginExample/nbproject/project.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@
5454
<specification-version>0.8</specification-version>
5555
</run-dependency>
5656
</dependency>
57+
<dependency>
58+
<code-name-base>org.openide.util</code-name-base>
59+
<build-prerequisite/>
60+
<compile-dependency/>
61+
<run-dependency>
62+
<specification-version>8.15.1</specification-version>
63+
</run-dependency>
64+
</dependency>
5765
<dependency>
5866
<code-name-base>org.openide.util.lookup</code-name-base>
5967
<build-prerequisite/>

PreviewPluginExample/src/org/gephi/plugins/example/preview/Bundle.properties

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ OpenIDE-Module-Long-Description=\
55
</li>\n<li><b>Glow Renderer:</b> Adds a new renderer for node items which draws a glow effect around nodes.\
66
</li>\n<li><b>Node Z-ordering:</b> Extends the default node builder by reordeing the node items by size or any number columns. \
77
Also shows how to create complex Preview UI.\
8+
</li>\n<li><b>Square shaped nodes:</b> Demonstrates how to extend and replace a default renderer. \
9+
Extends node default renderer to support square shaped nodes.\
810
</li>\n</ul>
911
OpenIDE-Module-Name=PreviewPluginExample
1012
OpenIDE-Module-Short-Description=Preview plugins example
13+
GlowRenderer.name=Glow on nodes
14+
HighlighMutualEdges.name=Highlight mutual edges
15+
SquareNodes.name=Nodes as circles or squares
16+
SquareNodes.property.name=Enable square shaped nodes
17+
SquareNodes.property.description=Enable nodes with square shape

PreviewPluginExample/src/org/gephi/plugins/example/preview/GlowRenderer.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Development and Distribution License("CDDL") (collectively, the
5757
import org.gephi.preview.plugin.items.NodeItem;
5858
import org.gephi.preview.plugin.renderers.NodeRenderer;
5959
import org.gephi.preview.spi.Renderer;
60+
import org.openide.util.NbBundle;
6061
import org.openide.util.lookup.ServiceProvider;
6162
import processing.core.PGraphicsJava2D;
6263

@@ -82,10 +83,16 @@ Development and Distribution License("CDDL") (collectively, the
8283
*/
8384
@ServiceProvider(service = Renderer.class, position = 10)
8485
public class GlowRenderer implements Renderer {
86+
8587

8688
//Custom properties
8789
public static final String ENABLE_NODE_GLOW = "node.glow.enable";
8890

91+
@Override
92+
public String getDisplayName() {
93+
return NbBundle.getMessage(GlowRenderer.class, "GlowRenderer.name");
94+
}
95+
8996
@Override
9097
public void preProcess(PreviewModel pm) {
9198
}

PreviewPluginExample/src/org/gephi/plugins/example/preview/HighlighMutualEdges.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Development and Distribution License("CDDL") (collectively, the
5050
import org.gephi.preview.plugin.items.EdgeItem;
5151
import org.gephi.preview.plugin.renderers.EdgeRenderer;
5252
import org.gephi.preview.spi.Renderer;
53+
import org.openide.util.NbBundle;
5354
import org.openide.util.lookup.ServiceProvider;
5455

5556
/**
@@ -88,6 +89,11 @@ public class HighlighMutualEdges implements Renderer {
8889
//Default values
8990
protected boolean defaultHighlightMutualEdges = false;
9091
protected Color defaultHighlightColor = Color.RED;
92+
93+
@Override
94+
public String getDisplayName() {
95+
return NbBundle.getMessage(HighlighMutualEdges.class, "HighlighMutualEdges.name");
96+
}
9197

9298
@Override
9399
public void preProcess(PreviewModel previewModel) {
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/*
2+
Copyright 2008-2011 Gephi
3+
Authors : Eduardo Ramos <eduramiba@gmail.com>
4+
Website : http://www.gephi.org
5+
6+
This file is part of Gephi.
7+
8+
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
9+
10+
Copyright 2011 Gephi Consortium. All rights reserved.
11+
12+
The contents of this file are subject to the terms of either the GNU
13+
General Public License Version 3 only ("GPL") or the Common
14+
Development and Distribution License("CDDL") (collectively, the
15+
"License"). You may not use this file except in compliance with the
16+
License. You can obtain a copy of the License at
17+
http://gephi.org/about/legal/license-notice/
18+
or /cddl-1.0.txt and /gpl-3.0.txt. See the License for the
19+
specific language governing permissions and limitations under the
20+
License. When distributing the software, include this License Header
21+
Notice in each file and include the License files at
22+
/cddl-1.0.txt and /gpl-3.0.txt. If applicable, add the following below the
23+
License Header, with the fields enclosed by brackets [] replaced by
24+
your own identifying information:
25+
"Portions Copyrighted [year] [name of copyright owner]"
26+
27+
If you wish your version of this file to be governed by only the CDDL
28+
or only the GPL Version 3, indicate your decision by adding
29+
"[Contributor] elects to include this software in this distribution
30+
under the [CDDL or GPL Version 3] license." If you do not indicate a
31+
single choice of license, a recipient has the option to distribute
32+
your version of this file under either the CDDL, the GPL Version 3 or
33+
to extend the choice of license to its licensees as provided above.
34+
However, if you add GPL Version 3 code and therefore, elected the GPL
35+
Version 3 license, then the option applies only if the new code is
36+
made subject to such option by the copyright holder.
37+
38+
Contributor(s):
39+
40+
Portions Copyrighted 2011 Gephi Consortium.
41+
*/
42+
package org.gephi.plugins.example.preview;
43+
44+
import java.awt.Color;
45+
import org.gephi.preview.api.*;
46+
import org.gephi.preview.plugin.items.NodeItem;
47+
import org.gephi.preview.plugin.renderers.NodeRenderer;
48+
import org.gephi.preview.spi.Renderer;
49+
import org.gephi.preview.types.DependantColor;
50+
import org.openide.util.NbBundle;
51+
import org.openide.util.lookup.ServiceProvider;
52+
import processing.core.PGraphics;
53+
54+
/**
55+
* Extends and replaces default nodes renderer and implements square shaped nodes.
56+
* <p>
57+
* By specifically extending a preview default renderer, this replaces it and the old one is no longer available.
58+
* A default renderer can be extended in order to add more features to it, or simply replace it completely.
59+
* Default renderers are contained in <code>org.gephi.preview.plugin.renderers</code> package.
60+
* <p>
61+
* Note that we need to set the position parameter even this replaces other renderer.
62+
* In this case and normally, the position has been set the same that the replaced renderer has (300).
63+
* @author Eduardo Ramos<eduramiba@gmail.com>
64+
*/
65+
@ServiceProvider(service = Renderer.class, position=300)
66+
public class SquareNodes extends NodeRenderer {
67+
68+
@Override
69+
public String getDisplayName() {
70+
return NbBundle.getMessage(SquareNodes.class, "SquareNodes.name");
71+
}
72+
73+
@Override
74+
public void render(Item item, RenderTarget target, PreviewProperties properties) {
75+
if (properties.getBooleanValue("SquareNodes.property.enable")) {
76+
if (target instanceof ProcessingTarget) {
77+
renderSquaresProcessing(item, (ProcessingTarget) target, properties);
78+
} else if (target instanceof SVGTarget) {
79+
renderSquaresSVG(item, (SVGTarget) target, properties);
80+
} else if (target instanceof PDFTarget) {
81+
renderSquaresPDF(item, (PDFTarget) target, properties);
82+
}
83+
} else {
84+
super.render(item, target, properties);
85+
}
86+
}
87+
88+
public void renderSquaresProcessing(Item item, ProcessingTarget target, PreviewProperties properties) {
89+
//Params
90+
Float x = item.getData(NodeItem.X);
91+
Float y = item.getData(NodeItem.Y);
92+
Float size = item.getData(NodeItem.SIZE);
93+
Color color = item.getData(NodeItem.COLOR);
94+
Color borderColor = ((DependantColor) properties.getValue(PreviewProperty.NODE_BORDER_COLOR)).getColor(color);
95+
float borderSize = properties.getFloatValue(PreviewProperty.NODE_BORDER_WIDTH);
96+
int alpha = (int) ((properties.getFloatValue(PreviewProperty.NODE_OPACITY) / 100f) * 255f);
97+
if (alpha > 255) {
98+
alpha = 255;
99+
}
100+
101+
//Graphics
102+
PGraphics graphics = target.getGraphics();
103+
104+
if (borderSize > 0) {
105+
graphics.stroke(borderColor.getRed(), borderColor.getGreen(), borderColor.getBlue(), alpha);
106+
graphics.strokeWeight(borderSize);
107+
} else {
108+
graphics.noStroke();
109+
}
110+
graphics.fill(color.getRed(), color.getGreen(), color.getBlue(), alpha);
111+
graphics.rect(x, y, size, size);
112+
}
113+
114+
public void renderSquaresPDF(Item item, PDFTarget target, PreviewProperties properties) {
115+
//TODO Not implemented
116+
}
117+
118+
public void renderSquaresSVG(Item item, SVGTarget target, PreviewProperties properties) {
119+
//TODO Not implemented
120+
}
121+
122+
@Override
123+
public PreviewProperty[] getProperties() {
124+
//Creates the same properties as the default renderer
125+
//but adds a new one to control square shaped nodes rendering
126+
PreviewProperty[] props = super.getProperties();
127+
PreviewProperty[] newProps = new PreviewProperty[props.length + 1];
128+
129+
for (int i = 0; i < props.length; i++) {
130+
newProps[i] = props[i];
131+
}
132+
133+
newProps[newProps.length - 1] = PreviewProperty.createProperty(this, "SquareNodes.property.enable", Boolean.class,
134+
NbBundle.getMessage(SquareNodes.class, "SquareNodes.property.name"),
135+
NbBundle.getMessage(SquareNodes.class, "SquareNodes.property.description"),
136+
PreviewProperty.CATEGORY_NODES).setValue(false);
137+
return newProps;
138+
}
139+
}

ProcessorPluginExample/nbproject/build-impl.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*** GENERATED FROM project.xml - DO NOT EDIT ***
44
*** EDIT ../build.xml INSTEAD ***
55
-->
6-
<project name="org.gephi.plugins.processor.example-impl" basedir="..">
6+
<project name="org.gephi.plugins.example.processor-impl" basedir="..">
77
<fail message="Please build using Ant 1.7.1 or higher.">
88
<condition>
99
<not>

0 commit comments

Comments
 (0)