This page (revision-58) was last changed on 23-Apr-2014 13:29 by Jochen Reutelshöfer

This page was created on 17-Dec-2012 09:13 by Jochen Reutelshöfer

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Page revision history

Version Date Modified Size Author Changes ... Change note
58 23-Apr-2014 13:29 5 KB Jochen Reutelshöfer to previous
57 17-Dec-2012 19:18 5 KB Jochen Reutelshöfer to previous | to last
56 17-Dec-2012 17:49 5 KB constin to previous | to last
55 17-Dec-2012 14:47 5 KB constin to previous | to last
54 17-Dec-2012 14:46 5 KB constin to previous | to last
53 17-Dec-2012 14:19 5 KB Jochen Reutelshöfer to previous | to last
52 17-Dec-2012 13:36 5 KB Tim Baier-Loewenstein to previous | to last
51 17-Dec-2012 12:19 5 KB Jochen Reutelshöfer to previous | to last
50 17-Dec-2012 12:19 5 KB Jochen Reutelshöfer to previous | to last
49 17-Dec-2012 12:17 4 KB Jochen Reutelshöfer to previous | to last
48 17-Dec-2012 12:16 4 KB Jochen Reutelshöfer to previous | to last
47 17-Dec-2012 12:14 4 KB Jochen Reutelshöfer to previous | to last
46 17-Dec-2012 12:13 4 KB Jochen Reutelshöfer to previous | to last
45 17-Dec-2012 12:05 4 KB Jochen Reutelshöfer to previous | to last
44 17-Dec-2012 11:59 4 KB Jochen Reutelshöfer to previous | to last
43 17-Dec-2012 11:57 3 KB Jochen Reutelshöfer to previous | to last
42 17-Dec-2012 11:54 3 KB Jochen Reutelshöfer to previous | to last
41 17-Dec-2012 11:39 3 KB Jochen Reutelshöfer to previous | to last

Page References

Incoming links Outgoing links

Version management

Difference between version and

At line 10 removed 2 lines
To create a new markup based on DefaultMarkup, the class ''[DefaultMarkupType|https://isci.informatik.uni-wuerzburg.de/javadoc/KnowWE/de/knowwe/kdom/defaultMarkup/DefaultMarkupType.html]''
needs to be extended. The following code snipplet shows a Hello-World extension of DefaultMarkup.
At line 13 changed one line
%%prettify
To create a new markup based on DefaultMarkup, the class ''de.knowwe.kdom.defaultMarkup.DefaultMarkupType'' needs to be extended. The following code snipplet shows a Hello-World extension of DefaultMarkup.
At line 15 changed 14 lines
1| public class HelloWorldMarkup extends DefaultMarkupType {
2|
3| private static final DefaultMarkup MARKUP;
4|
5| static {
6| MARKUP = new DefaultMarkup("HelloWorld");
7| }
8|
9| public HelloWorldMarkup() {
10| super(MARKUP);
11| }
12| }
}}}
/%
public class HelloWorldMarkup extends DefaultMarkupType {
At line 30 changed 5 lines
A private instance of a [DefaultMarkup|https://isci.informatik.uni-wuerzburg.de/javadoc/KnowWE/de/knowwe/kdom/defaultMarkup/DefaultMarkup.html] is required (line 3).
The initialization of the DefaultMarkup object in the static block (line 6) is required in that way to allow the plugin-framework to create a markup instance on start-up.
In line 6 also the name (and markup keyword) is specified as parameter for the DefaultMarkup object, "HelloWorld" in this example.
The DefaultMarkup object has to be passed to the super class constructor call, as shown in line 10.
! Add Annotations
private static final DefaultMarkup MARKUP;
At line 36 changed one line
In the following the above listing is extended in line 4 and line 8 to introduce an annotation. The markup example allows to specify an image file name by the ''image'' annotation.
static {
MARKUP = new DefaultMarkup("HelloWorld");
}
At line 38 changed 16 lines
%%prettify
{{{
1| public class HelloWorldMarkup extends DefaultMarkupType {
2|
3| private static final DefaultMarkup MARKUP;
4| public static final String IMAGE_KEY = "image";
5|
6| static {
7| MARKUP = new DefaultMarkup("HelloWorld");
8| MARKUP.addAnnotation(Image_KEY, false);
9| }
10|
11| public HelloWorldMarkup() {
12| super(MARKUP);
13| }
14| }
public HelloWorldMarkup() {
super(MARKUP);
}
}
At line 55 removed one line
/%
At line 29 added one line
The initialization of the DefaultMarkup object in the static block is required in that way to allow the plugin-framework to create a markup instance on start-up.
At line 31 added one line
! Add Annotations
At line 59 changed 3 lines
! Create a renderer
In principle any kind of renderer can be added to render the markup. However, it is recommended to use a renderer based on the [DefaultMarkupRenderer|https://isci.informatik.uni-wuerzburg.de/javadoc/KnowWE/de/knowwe/kdom/defaultMarkup/DefaultMarkupRenderer.html] to provide a coherent look of all content element. Further, this renderer automatically gives access to additional tool extensions that are registered for this markup ([HowTo Create Tools]).
The renderer can be set in the constructor as shown in line 3 of the following listing:
{{{
public class HelloWorldMarkup extends DefaultMarkupType {
At line 36 added 3 lines
public static final String IMAGE_KEY = "image";
private static final DefaultMarkup MARKUP;
At line 64 changed 6 lines
%%prettify
{{{
1| public HelloWorldMarkup() {
2| super(MARKUP);
3| this.setRenderer(new HelloWorldRenderer());
4| }
static {
MARKUP = new DefaultMarkup("HelloWorld");
MARKUP.addAnnotation(Image_KEY, false);
}
public HelloWorldMarkup() {
super(MARKUP);
}
}
At line 71 removed one line
/%
At line 52 added 2 lines
! Create a renderer
At line 74 removed one line
To make the markup active in KnowWE it has to be registered to the plugin-framework. This is done by an entry into the [plugin.xml|Meaning of plugin.xml] file.
At line 76 removed one line
The extension point for markups is called ''Type''. The code to register the markup defined above on the root level, i.e., making it available as root level content element on any page, would look like this:
At line 78 removed 15 lines
%%prettify
{{{
<extension plugin-id="KnowWEExtensionPoints" point-id="Type"
id="HelloKnowWEType">
<parameter id="class"
value="de.knowwe.example.HelloKnowWEType" />
<parameter id="name" value="HelloKnowWEType" />
<parameter id="description" value="KnowWEObjectType HelloKnowWEType" />
<parameter id="version" value="1.0" />
<parameter id="priority" value="5" />
<parameter id="scope" value="root" />
</extension>
}}}
/%
At line 94 removed one line
In rare cases it is necessary to create markups that are not based on the DefaultMarkup template. One case is for example, when the new markup is not meant to be a self-contained section on root level, but an extension of an existing markup.
At line 96 removed 6 lines
To create a general markup you should be familiar with implementing [Types|Type] and parsing (using [Sectionfinders|SectionFinder].
The class [AbstractType|https://isci.informatik.uni-wuerzburg.de/javadoc/KnowWE/de/knowwe/core/kdom/AbstractType.html] has to be extended.
More details about parsing in KnowWE can be found here:
%%todo link to page about parsing
If the markup is an extension to an existing one and not on root level, the class name of the parent type needs to be specified within the scope parameter of the plugin.xml. __Note:__ Be aware that additional/multiple sub-types injected to the same parent type are 'competing' for the content in a priority-based manner and therefore might interfere with each other on the parsing process.
At line 103 changed one line
howto create Markup plugin.xml
howto
At line 105 removed one line