Child pages
  • KIML
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

This exercise will introduce the usage of the Eclipse Plugin Development Environment for developing new layout algorithms to be used in Eclipse diagram editors. Replace each <login> by your own login name (e.g. msp), and each <Login> by your login name with capitalized first letter (e.g. Msp). For any questions contact msp.

  1. Install and set up Eclipse
  2. Check out the following KIELER plugins:
    • de.cau.cs.kieler.core
    • de.cau.cs.kieler.core.kgraph
    • de.cau.cs.kieler.core.kgraph.edit
    • de.cau.cs.kieler.core.ui
    • de.cau.cs.kieler.keg
    • de.cau.cs.kieler.keg.diagram
    • de.cau.cs.kieler.kiml.layout
    • de.cau.cs.kieler.kiml.ui
    • de.cau.cs.kieler.kiml.viewer
    • de.cau.cs.kieler.klay.layered
  3. Create a new plugin
    1. File -> New -> Other... -> Plug-in Development -> Plug-in Project
    2. Project name: de.cau.cs.rtprak.<login>.exercise1
    3. Next -> set version to 0.1.0.qualifier, provider to Christian-Albrechts-Universität zu Kiel, and execution environment to J2SE-1.5 (do this for all plugins that you create!)
    4. The checkboxes in the Options group can be deactivated -> Finish
  4. Check in the new plugin project into https://rtsys.informatik.uni-kiel.de/svn/teaching/prak/10ss-layout/exercises/<login>/
  5. Activate Checkstyle: right-click the project -> Properties -> Checkstyle -> Checkstyle active for this project
  6. Open the file META-INF/MANIFEST.MF -> Dependencies tab
    • Add the plugins de.cau.cs.kieler.core and de.cau.cs.kieler.kiml.layout to the list of dependencies, then save the file
  7. Create a layout provider class with the New -> Class wizard
    • Package: de.cau.cs.rtprak.<login>.exercise1
    • Name: <Login>LayoutProvider
    • Superclass: de.cau.cs.kieler.kiml.AbstractLayoutProvider
  8. Implement the  layout provider class
    1. You should now see a checkstyle warning for the doLayout method
      • Add the keyword final to each method argument to eliminate the warning
    2. Add the following constant to the class:
          /** default value for spacing between nodes. */
          private static final float DEFAULT_SPACING = 15.0f;
      
    3. Write the following lines at the beginning of the doLayout method (see  IKielerProgressMonitor and  KimlLayoutUtil):
              progressMonitor.begin("<Login> Layouter", 1);
              KShapeLayout parentLayout = layoutNode.getData(KShapeLayout.class);
              float objectSpacing = parentLayout.getProperty(LayoutOptions.SPACING);
              if (objectSpacing < 0) {
                  objectSpacing = DEFAULT_SPACING;
              }
              float borderSpacing = parentLayout.getProperty(LayoutOptions.BORDER_SPACING);
              if (borderSpacing < 0) {
                  borderSpacing = DEFAULT_SPACING;
              }
      
    4. Write the following line at the end of the doLayout method:
              progressMonitor.done();
      
    5. Implement the rest of the layouter such that the nodes of the input graph are all put in a row
      • See the  KGraph and  KLayoutData data structures: the input is a  KNode and holds the nodes of the graph in its list of children
      • Iterate over the nodes in the  getChildren() list of the layoutNode input
      • Retrieve the size of a node using the following code:
                KShapeLayout nodeLayout = node.getData(KShapeLayout.class);
                float width = nodeLayout.getWidth();
                float height = nodeLayout.getHeight();
        
      • Set the position (x, y) of a node's upper left corner using the following code:
                nodeLayout.setXpos(x);
                nodeLayout.setYpos(y);
        
      • objectSpacing shall be the spacing to be left between each pair of nodes
      • borderSpacing shall be the spacing to be left to the borders of the drawing: the first node's coordinates shall be (borderSpacing, borderSpacing)
      • At the end of the method, set the width and height of parentLayout so that it is large enough to hold the whole drawing, including borders
      • Edges may be ignored for now
  9. Open the file META-INF/MANIFEST.MF -> Extensions tab
    1. Add an extension for de.cau.cs.kieler.kiml.layout.layoutProviders
    2. Right-click the extension -> New -> layoutProvider
    3. Set name to <Login> Test Layouterclass to de.cau.cs.rtprak.<login>.exercise1.<Login>LayoutProvider
    4. Right-click the new layoutProvider -> New -> knownOption, set option to de.cau.cs.kieler.layout.options.minSpacing
    5. Add another knownOption, set to de.cau.cs.kieler.layout.options.borderSpacing
  10. Run -> Run Configurations... -> right-click Eclipse Application -> New
    1. Name: Layout
    2. For testing the layouter, a new workspace location will be created; you may configure its destination in Workspace Data -> Location
    3. Add the program arguments -debug -consoleLog in the Arguments tab
    4. Go to Plug-ins tab, select Launch with: plug-ins selected below only
    5. Deselect All, activate Workspace checkbox, Add Required Plug-insApplyRun
  11. Test the layouter in the new Eclipse instance:
    1. New -> Project... -> General -> Project, name test
    2. Right-click test project -> New -> Other... -> Graphs Diagram
    3. Create a graph using the palette on the right
    4. Window -> Show View -> Other... -> KIELER -> Layout
    5. While the graph diagram is open, set Layout Provider or Type in the Layout view to <Login> Test Layouter
    6. Open the additional views Layout Graph and Layout Time
    7. Trigger layout with KIELER -> Layout or Ctrl+R L (first Ctrl+R, then L) or the button in the toolbar
    8. See the direct input and output of your algorithm in the Layout Graph view: Pre-Layout is the input, Post-Layout is the output
    9. See the execution time analysis in the Layout Time view
  12. Implement another class EdgeRouter with superclass de.cau.cs.kieler.core.alg.AbstractAlgorithm
    1. Add the following method:
          /** * Route the edges that are connected with the children of the given node. * * @param parentNode the parent node of the input graph */
          public void routeEdges(final KNode parentNode) {
              getMonitor().begin("Edge Routing", 1);
              
              getMonitor().done();
          }
      
    2. Add the following code to the end of the doLayout method in your layout provider:
              EdgeRouter edgeRouter = new EdgeRouter();
              edgeRouter.reset(progressMonitor.subTask(1));
              edgeRouter.routeEdges(layoutNode);
      
    3. Implement the routeEdges method:
      • Each edge shall be drawn with three line segments: one vertical segment starting below the source node, one horizonzal segment, and another vertical segment ending below the target node.
      • The horizontal segments of two different edges shall not have the same y-coordinate; for consecutive edges, the distance between their horizontal segments shall equal objectSpacing
      • See the attached image test-drawing.png Download for an example
      • Find the edges using  getOutgoingEdges() or  getIncomingEdges() on a node
      • Get the edge layout of an edge to set bend points using this code:
                KEdgeLayout edgeLayout = edge.getData(KEdgeLayout.class);
        
      • Create a bend point using this code:
                KPoint point = KLayoutDataFactory.eINSTANCE.createKPoint();
        
      • Use the  getBendPoints() list on the edgeLayout to add bend points (clear the list first to remove points from the previous layout)
      • Set the values of the points returned by  getSourcePoint() and  getTargetPoint() according to the positions where the edge leaves its source node and reches its target node
  13. Use your previous run configuration to test the edge router.
  • No labels