org.infai.emo.matcher.editor
Class ModelMatcherCanvas

java.lang.Object
  extended by org.infai.emo.matcher.editor.ModelMatcherCanvas
All Implemented Interfaces:
java.util.EventListener, org.eclipse.swt.events.MouseListener, org.eclipse.swt.internal.SWTEventListener

public class ModelMatcherCanvas
extends java.lang.Object
implements org.eclipse.swt.events.MouseListener

This class includes the canvas and a TableViewer below the canvas.
The canvas is used to draw the matching-lines between the models while the table is intended to show matching details.
Therefore this Class offers various methods for drawing lines, removing and updating them.
There are also methods provided for selecting lines and filling the table with informations.

Version:
1.1.5
Author:
Stanley Hillner
See Also:
MouseListener

Field Summary
private  LineCalculations calculator
          This variable contains the calculator for the line visualization.
private  org.eclipse.swt.widgets.Canvas canvas
          The canvas of the editor on which the matching is visualized.
private  org.eclipse.swt.widgets.Composite comp
          The composite on which the canvas, the tableViewer, ... are placed.
private  ModelMatcherEditor editor
          The editor which contains this "canvas" (this Class providing the Canvas and the Table) as a component.
private  org.eclipse.swt.graphics.Color lineColor
          This Color determines the base color for the visualization.
private  java.util.Vector<Line> lines
          This Vector buffers all the lines that are actually drawn on the canvas.
private  double stepSize
          This value shows the custom size of the visualization-steps.
private  org.eclipse.swt.widgets.Table table
          The table that provides detailed matching informations about the matching to the user.
private  org.eclipse.jface.viewers.TableViewer tableV
          The tableViewer that contains the table below the canvas.
private  double threshold
          This value shows the threshold for the drawing-operation.
private  org.eclipse.swt.events.PaintListener valuePL
          The PaintListener for the matching-value that stands beside the currently selected line.
 
Constructor Summary
ModelMatcherCanvas(org.eclipse.swt.widgets.Composite parent, ModelMatcherEditor editor, int style)
          Constructor initializes the canvas and the tableViewer on the given composite.
 
Method Summary
 void createGUI()
          Creates the graphical appearance of the canvas and the table.
private  void createTableItems(Line line)
          This method fills the table located under the canvas with the matching-details of the given line.
 void drawLine(int yLeft, int yRight, Tuple tuple, double value, boolean leftToRight)
          This method draws a matching-line on the canvas.
 org.eclipse.swt.widgets.Canvas getCanvas()
           
 ModelMatcherEditor getEditor()
           
 double getStepSize()
           
 double getThreshold()
           
 void loadConfigurationData()
          Loads the stored configuration for the graphical representation of the matching from the eclipse-preference-store for this plug-in.
 void mouseDoubleClick(org.eclipse.swt.events.MouseEvent e)
          
 void mouseDown(org.eclipse.swt.events.MouseEvent e)
          Activated by a click on the canvas.
 void mouseUp(org.eclipse.swt.events.MouseEvent e)
          
 void moveLines(int treeID, int scrollValue)
          This method moves the lines on the canvas in horizontal direction in the case that a tree has been scrolled.
 void preferencesChanged()
          Method is called after the preferences for the plug-in have changed so that all lines can be redrawn using the new settings.
private  void removeLastSelection()
          Removes the current selection of a line on the canvas if there is one.
 void removeLines()
          Removes all Lines from the canvas so that the canvas is prepared for a new set of matching-lines.
private  void selectLine(Line line)
          Selects the given line by drawing it fat and dashed.
 void setLayoutData(java.lang.Object layoutData)
          Set the given LayoutData to the composite that lies under the canvas and the table.
 void updateLines()
          Update the drawn lines in case of a change to the composite (like resizing it).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

canvas

private org.eclipse.swt.widgets.Canvas canvas
The canvas of the editor on which the matching is visualized.
This canvas is located on a Composite.

See Also:
comp, Canvas

tableV

private org.eclipse.jface.viewers.TableViewer tableV
The tableViewer that contains the table below the canvas.
This Viewer is located on a Composite.

See Also:
comp, TableViewer

table

private org.eclipse.swt.widgets.Table table
The table that provides detailed matching informations about the matching to the user.
This table is a child of the TableViewer below the canvas.

See Also:
tableV, Table

comp

private final org.eclipse.swt.widgets.Composite comp
The composite on which the canvas, the tableViewer, ... are placed.

See Also:
Composite

lines

private java.util.Vector<Line> lines
This Vector buffers all the lines that are actually drawn on the canvas.
If the canvas is cleared this buffer will also be empty until new lines are drawn.

See Also:
Vector, Line

threshold

private double threshold
This value shows the threshold for the drawing-operation.
Only matching-tuples will be visualized as a line theirs matching-value is equal or above the threshold.


stepSize

private double stepSize
This value shows the custom size of the visualization-steps.
That means that the range from the threshold to 1.0 is divided into parts of equal size, determined by the stepsize so that the lines can be drawn in different color-variations, depending on the matching-value.

matching-values that equal 1.0 are always black.


lineColor

private org.eclipse.swt.graphics.Color lineColor
This Color determines the base color for the visualization.
The tuples with the lowest matching-values are drawn using this color.
Others are visualized with a graded color-value based on this color.

See Also:
Color

editor

private ModelMatcherEditor editor
The editor which contains this "canvas" (this Class providing the Canvas and the Table) as a component.

See Also:
ModelMatcherEditor

valuePL

private org.eclipse.swt.events.PaintListener valuePL
The PaintListener for the matching-value that stands beside the currently selected line.

See Also:
PaintListener, Line

calculator

private LineCalculations calculator
This variable contains the calculator for the line visualization.
This calculator is able to calculate the size of a step of the visualization or the line-color for a line to be drawn depending on the matching-value.

See Also:
LineCalculations, Line
Constructor Detail

ModelMatcherCanvas

public ModelMatcherCanvas(org.eclipse.swt.widgets.Composite parent,
                          ModelMatcherEditor editor,
                          int style)
Constructor initializes the canvas and the tableViewer on the given composite.

Parameters:
parent - the parent Composite for this part of the editor. On this composite a new one, containing the canvas and the table, will be created.
editor - the editor which contains this canvas as a component.
style - the SWT-style for the new composite.
See Also:
Composite, editor, SWT
Method Detail

createGUI

public void createGUI()
Creates the graphical appearance of the canvas and the table.


setLayoutData

public void setLayoutData(java.lang.Object layoutData)
Set the given LayoutData to the composite that lies under the canvas and the table.

Parameters:
layoutData - the LayoutData for the composite.
See Also:
Control.setLayoutData(Object)

drawLine

public void drawLine(int yLeft,
                     int yRight,
                     Tuple tuple,
                     double value,
                     boolean leftToRight)
This method draws a matching-line on the canvas.
The line-color depends on the matching value. and the pre-selected line-color.

Parameters:
yLeft - the y-coordinate of the left ending of the line.
yRight - the y-coordinate of the right ending of the line.
tuple - the tuple containing the matched Objects that represent the endings of the line.
value - the matching-value that belongs to the tuple.
See Also:
lineColor, Line, Tuple

moveLines

public void moveLines(int treeID,
                      int scrollValue)
This method moves the lines on the canvas in horizontal direction in the case that a tree has been scrolled.
Therefore the ID of the tree is needed to move the right ending of the lines up or down by the given amount of pixels.

Parameters:
treeID - the ID of the tree that was scrolled.
scrollValue - the number of pixels the tree was scrolled.
If the tree scrolls down the value must be positive, negative if the tree scrolls up.
See Also:
ModelMatcherTreeViewer.getTreeID()

updateLines

public void updateLines()
Update the drawn lines in case of a change to the composite (like resizing it).
This method uses the actual size-values of all involved components.


removeLines

public void removeLines()
Removes all Lines from the canvas so that the canvas is prepared for a new set of matching-lines.
This method does also clear the line-buffer (lines).


getCanvas

public org.eclipse.swt.widgets.Canvas getCanvas()
Returns:
the Canvas on which the lines are drawn.
See Also:
canvas

getThreshold

public double getThreshold()
Returns:
the threshold that represents the minimum matching-value from which the lines will be drawn.
See Also:
threshold

getStepSize

public double getStepSize()
Returns:
the size of the steps in which the matching-values will be drawn using different colors.
See Also:
stepSize

mouseDoubleClick

public void mouseDoubleClick(org.eclipse.swt.events.MouseEvent e)

Specified by:
mouseDoubleClick in interface org.eclipse.swt.events.MouseListener

mouseUp

public void mouseUp(org.eclipse.swt.events.MouseEvent e)

Specified by:
mouseUp in interface org.eclipse.swt.events.MouseListener

mouseDown

public void mouseDown(org.eclipse.swt.events.MouseEvent e)
Activated by a click on the canvas.
Searches for the position of the click and determines whether there is a line or not.
If there is a line this method ensures that this line will be selected.

Specified by:
mouseDown in interface org.eclipse.swt.events.MouseListener

removeLastSelection

private void removeLastSelection()
Removes the current selection of a line on the canvas if there is one. After this method was called, valuePL is set to null.


selectLine

private void selectLine(Line line)
Selects the given line by drawing it fat and dashed.
The method also draws the lines matching-value on the canvas. After this method was called valuePL cannot be null.

Parameters:
line - the line to be selected.
See Also:
Line

createTableItems

private void createTableItems(Line line)
This method fills the table located under the canvas with the matching-details of the given line.
The table is filled by the names of the atomic comparators and the values of the comparisons.

Parameters:
line - the line of which the comparison-details shall be displayed.
See Also:
Line

getEditor

public ModelMatcherEditor getEditor()
Returns:
the editor which contains this component.
See Also:
editor

loadConfigurationData

public void loadConfigurationData()
Loads the stored configuration for the graphical representation of the matching from the eclipse-preference-store for this plug-in.


preferencesChanged

public void preferencesChanged()
Method is called after the preferences for the plug-in have changed so that all lines can be redrawn using the new settings.