Skip to content

Commit

Permalink
version 2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarkov committed Apr 24, 2020
1 parent 3d19391 commit d4af30d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 39 deletions.
58 changes: 26 additions & 32 deletions src/main/java/org/vanted/addons/exampleaddon/ExemplaryAddon.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
import de.ipk_gatersleben.ag_nw.graffiti.plugins.addons.AddonAdapter;

/**
* @author Hendrik Rohn
* Use {@link AddonAdapter} to indicate, that you are writing an addon.
* If an exception occurs during instantiation, a proper error message
* will be thrown and a standard addon icon will be used.
* @author Hendrik Rohn Use {@link AddonAdapter} to indicate, that you are
* writing an addon. If an exception occurs during instantiation, a
* proper error message will be thrown and a standard addon icon will be
* used.
*/
public class ExemplaryAddon extends AddonAdapter {

/**
* This class will automatically start all implemented Algorithms, views and
* other extensions written in your Add-on. A code formatting template
Expand All @@ -49,7 +49,7 @@ protected void initializeAddon() {
// registers a (number of) Tabs in the sidepanel, on which you may add
// any Jcomponent you want to
this.tabs = new InspectorTab[] { new AddonTab() };

// registers a number of algorithms which can manipulate graphs (and
// views, if they are editoralgorithms)
this.algorithms = new Algorithm[] {
Expand All @@ -67,27 +67,26 @@ protected void initializeAddon() {
// another algorithm adding nice stars to graphelements and
// implements undi functionality
new AddStarsToGraphElements()

};

// registers a number of views, which can be created from code or via
// File->New View (you can also decide not to register, but just to create
// such views from code.
this.views = new String[] { MyFirstView.class.getName() };

// registers a new Button in the Toolbar
this.guiComponents = new GraffitiComponent[] {
new ToolbarButton("defaultToolbar", WindowOrder.HORIZONTAL),
this.guiComponents = new GraffitiComponent[] { new ToolbarButton("defaultToolbar", WindowOrder.HORIZONTAL),
new ToolbarButton("defaultToolbar", WindowOrder.VERTICAL),
new ToolbarButton("defaultToolbar", WindowOrder.QUADRATIC) };

// registers a new Attribute
this.attributes = new Class[1];
this.attributes[0] = StarAttribute.class;

// registers this attribute as a special string attribute
StringAttribute.putAttributeType(StarAttribute.name, StarAttribute.class);

// registers, that the attribute with a certain name is instance of a
// class and how it will be displayed in the AttributeEditor
// note that "Stars: Stars" will lead to clustering all attributes
Expand All @@ -96,47 +95,42 @@ protected void initializeAddon() {
// the complete
// name, e.g. ".graphics.stars"
this.attributeDescriptions = new AttributeDescription[] {
new AttributeDescription(StarAttribute.name,
StarAttribute.class, "Stars: Stars", true, false, null), };

new AttributeDescription(StarAttribute.name, StarAttribute.class, "Stars: Stars", true, false, null), };

// as an alternative to using attributedescriptions, one may also specify
// a nice attribute description with this command:
// AttributeHelper.setNiceId("starsize", "Stars: Size");

// registers an editor for the star-Attribute
valueEditComponents.put(StarAttribute.class, StarAttributeEditor.class);

// registers a component for the attribute, to visualise the star
attributeComponents.put(StarAttribute.class, StarAttributeComponent.class);

// registers deleteable attributes, just hover over the name and click
AttributeHelper.setDeleteableAttribute("." + StarAttribute.path + ".", StarAttribute.path);

// this attribute will not serialized (saved in the gml file)
// AttributeManager.getInstance().addUnwrittenAttribute("." + StarAttribute.path + "." + StarAttribute.name);

// AttributeManager.getInstance().addUnwrittenAttribute("." + StarAttribute.path
// + "." + StarAttribute.name);

// registers a serializer to write a graph-file to any format
// inputserializers should extend AbstractInputSerializer
outputSerializers = new OutputSerializer[] {
new TestWriter()
};
outputSerializers = new OutputSerializer[] { new TestWriter() };
}

/**
* Here you may specify your own logo, which will appear in menus and tabs.
*/
@Override
public ImageIcon getIcon() {
try {
ImageIcon icon = new ImageIcon(GravistoService.getResource(this.getClass(), "starspace", "png"));
if (icon != null)
return icon;
else
return super.getIcon();
return icon;
} catch (Exception e) {
ErrorMsg.addErrorMessage(e);
return super.getIcon();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
*/
public class StarAttributeEditor extends AbstractValueEditComponent {

private final JComboBox checkbox;
private final JComboBox<String> checkbox;
public static String[] validStarSettings = new String[] { "0", "1", "2", "3",
"4", "5" };

public StarAttributeEditor(Displayable disp) {
super(disp);
checkbox = new JComboBox(validStarSettings);
checkbox = new JComboBox<String>(validStarSettings);
checkbox.setOpaque(false);
checkbox.setSelectedItem(disp.getValue());
}
Expand Down
8 changes: 3 additions & 5 deletions src/main/resources/Add-on-Example.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@

<plugin>
<author>Matthias Klapperstueck</author>
<description>Extends VANTED to show how you can write Add-ons for VANTED. There are plenty of extension possibilities available (algorithms, context-menu entries,...).</description>
<description>This Add-on serves as an example on how to extend VANTED. VANTED can be extended in many ways: via new algorithms, tools, file formats, etc.</description>
<plugindesc>
<name>Exemplary Add-on</name>
<main>org.vanted.addons.exampleaddon.ExemplaryAddon</main>
<version>2.0</version>
<feedname>Example-Add-on Changelog</feedname>
<feedurl>https://immersive-analytics.infotech.monash.edu/vanted/addons/example/rss-changelog.xml</feedurl>
<version>2.0.1</version>
<compatibility>2.5.0</compatibility>
<available>https://bitbucket.org/matthiak/vanted-addon-example/</available>
<available>https://github.com/LSI-UniKonstanz/vanted-addon-example/</available>
</plugindesc>
</plugin>

0 comments on commit d4af30d

Please sign in to comment.