Skip to content
Snippets Groups Projects
Commit cfb4b656 authored by Kevin Kassin's avatar Kevin Kassin
Browse files

#Commit 29.7 12:50

added javadoc for the code of the last commit,
made changes to the visual style of constraints
parent 3e07751c
No related branches found
No related tags found
No related merge requests found
Showing
with 94 additions and 22 deletions
...@@ -27,12 +27,14 @@ public class LayoutLiterals { ...@@ -27,12 +27,14 @@ public class LayoutLiterals {
* (1) the color of text or<br> * (1) the color of text or<br>
* (2) the color of lines or<br> * (2) the color of lines or<br>
* (3) the color of backgrounds or<br> * (3) the color of backgrounds or<br>
* (4) the color of graphiti shapes shadows * (4) the color of graphiti shapes shadows or<br>
* (5) the color of constraint texts and connections
*/ */
public static final IColorConstant COLOR_TEXT = IColorConstant.BLACK, public static final IColorConstant COLOR_TEXT = IColorConstant.BLACK,
COLOR_LINES = IColorConstant.BLACK, COLOR_LINES = IColorConstant.BLACK,
COLOR_BACKGROUND = IColorConstant.WHITE, COLOR_BACKGROUND = IColorConstant.WHITE,
COLOR_SHADOW = IColorConstant.GRAY; COLOR_SHADOW = IColorConstant.GRAY,
COLOR_CONSTRAINTS = IColorConstant.DARK_GRAY;
/** /**
* layout integer for wizards * layout integer for wizards
......
...@@ -5,6 +5,11 @@ import java.util.Map; ...@@ -5,6 +5,11 @@ import java.util.Map;
import org.framed.iorm.ui.literals.NameLiterals; import org.framed.iorm.ui.literals.NameLiterals;
/**
* This static class is used to get information about when and where a feature with a specific name
* is shown in the palette.
* @author Kevin Kassin
*/
public class FeatureManager { public class FeatureManager {
/** /**
...@@ -37,25 +42,36 @@ public class FeatureManager { ...@@ -37,25 +42,36 @@ public class FeatureManager {
RELATIONSHIP_IMPLICATION_FEATURE_NAME = NameLiterals.RELATIONSHIP_IMPLICATION_FEATURE_NAME, RELATIONSHIP_IMPLICATION_FEATURE_NAME = NameLiterals.RELATIONSHIP_IMPLICATION_FEATURE_NAME,
RELATIONSHIP_EXCLUSION_FEATURE_NAME = NameLiterals.RELATIONSHIP_EXCLUSION_FEATURE_NAME; RELATIONSHIP_EXCLUSION_FEATURE_NAME = NameLiterals.RELATIONSHIP_EXCLUSION_FEATURE_NAME;
//TODO krzel /**
* simple short forms of the palette categories to make code more readable
*/
private static PaletteCategory entities = PaletteCategory.ENTITIES_CATEGORY, private static PaletteCategory entities = PaletteCategory.ENTITIES_CATEGORY,
properties = PaletteCategory.PROPERTIES_CATEGORY, properties = PaletteCategory.PROPERTIES_CATEGORY,
relations = PaletteCategory.RELATIONS_CATEGORY, relations = PaletteCategory.RELATIONS_CATEGORY,
constraints = PaletteCategory.CONSTRAINTS_CATEGORY, constraints = PaletteCategory.CONSTRAINTS_CATEGORY,
none = PaletteCategory.NONE; none = PaletteCategory.NONE;
/**
* simple short forms of the view visibility to make code more readable
*/
private static ViewVisibility all = ViewVisibility.ALL_VIEWS, private static ViewVisibility all = ViewVisibility.ALL_VIEWS,
top = ViewVisibility.TOPLEVEL_VIEW, top = ViewVisibility.TOPLEVEL_VIEW,
compartment = ViewVisibility.COMPARTMENT_VIEW, compartment = ViewVisibility.COMPARTMENT_VIEW,
no_view = ViewVisibility.NO_VIEW; no_view = ViewVisibility.NO_VIEW;
/**
//TODO * the map that saves when and where a feature with a specific name is shown in the palette
*/
public static Map<String, FeaturePaletteDescriptor> features = createFeatureCategoryMap(); public static Map<String, FeaturePaletteDescriptor> features = createFeatureCategoryMap();
/** /**
* TODO * creates the map that saves when and where a feature with a specific name is shown in the palette
* Step 1 features in none of the categories * using the following steps:
* <p>
* Step 1: features shown in none of the categories<br>
* Step 2: features shown in the category "Entities"<br>
* Step 3: features shown in the category "Properties"<br>
* Step 4: features shown in the category "Relations"<br>
* Step 5: features shown in the category "Constraints"<br>
* @return * @return
*/ */
private static Map<String, FeaturePaletteDescriptor> createFeatureCategoryMap() { private static Map<String, FeaturePaletteDescriptor> createFeatureCategoryMap() {
......
package org.framed.iorm.ui.palette; package org.framed.iorm.ui.palette;
/**
* An object of this class describes when and where to show a feature in the palette.
* @author Kevin Kassin
*/
public class FeaturePaletteDescriptor { public class FeaturePaletteDescriptor {
/**
* in which category to show a feature in the palette
*/
public PaletteCategory paletteCategory = PaletteCategory.NONE; public PaletteCategory paletteCategory = PaletteCategory.NONE;
/**
* depending on the current palette view when to show the feature in the palette
*/
public ViewVisibility viewVisibility = ViewVisibility.NO_VIEW; public ViewVisibility viewVisibility = ViewVisibility.NO_VIEW;
/**
* Class constructor
*/
public FeaturePaletteDescriptor(PaletteCategory paletteCategory, ViewVisibility viewVisibility) { public FeaturePaletteDescriptor(PaletteCategory paletteCategory, ViewVisibility viewVisibility) {
this.paletteCategory = paletteCategory; this.paletteCategory = paletteCategory;
this.viewVisibility = viewVisibility; this.viewVisibility = viewVisibility;
......
package org.framed.iorm.ui.palette; package org.framed.iorm.ui.palette;
import org.framed.iorm.ui.providers.ToolBehaviorProvider; //*import for javadoc link
/**
* This enum creates possible values to save in which category to show a feature in the palette. It is used in
* {@link FeatureManager} and the {@link ToolBehaviorProvider}.
* @author Kevin Kassin
*/
public enum PaletteCategory { public enum PaletteCategory {
ENTITIES_CATEGORY, ENTITIES_CATEGORY,
......
package org.framed.iorm.ui.palette; package org.framed.iorm.ui.palette;
/**
* This enumeration offers values for the palette views.
* @author Kevin Kassin
*/
public enum PaletteView { public enum PaletteView {
TOPLEVEL_VIEW, TOPLEVEL_VIEW,
......
package org.framed.iorm.ui.palette; package org.framed.iorm.ui.palette;
import org.framed.iorm.ui.providers.ToolBehaviorProvider; //*import for javadoc link
/**
* This enum creates possible values to save in which palette view to show a feature in the palette. It is used in
* {@link FeatureManager} and the {@link ToolBehaviorProvider}.
* @author Kevin Kassin
*/
public enum ViewVisibility { public enum ViewVisibility {
ALL_VIEWS, ALL_VIEWS,
......
...@@ -43,7 +43,7 @@ public class AbstractInterRelationshipConstraintPattern extends FRaMEDConnection ...@@ -43,7 +43,7 @@ public class AbstractInterRelationshipConstraintPattern extends FRaMEDConnection
/** /**
* the color values used for the polyline and the arrowhead gathered from {@link LayoutLiterals} * the color values used for the polyline and the arrowhead gathered from {@link LayoutLiterals}
*/ */
protected final IColorConstant COLOR_CONNECTIONS = LayoutLiterals.COLOR_CONNECTIONS, protected final IColorConstant COLOR_CONSTRAINTS = LayoutLiterals.COLOR_CONSTRAINTS,
COLOR_ARROWHEAD = LayoutLiterals.COLOR_ARROWHEAD; COLOR_ARROWHEAD = LayoutLiterals.COLOR_ARROWHEAD;
/** /**
...@@ -92,7 +92,7 @@ public class AbstractInterRelationshipConstraintPattern extends FRaMEDConnection ...@@ -92,7 +92,7 @@ public class AbstractInterRelationshipConstraintPattern extends FRaMEDConnection
connection.setStart(graphicalSourceAnchor); connection.setStart(graphicalSourceAnchor);
connection.setEnd(graphicalTargetAnchor); connection.setEnd(graphicalTargetAnchor);
Polyline polyline = graphicAlgorithmService.createPolyline(connection); Polyline polyline = graphicAlgorithmService.createPolyline(connection);
polyline.setForeground(manageColor(COLOR_CONNECTIONS)); polyline.setForeground(manageColor(COLOR_CONSTRAINTS));
polyline.setLineStyle(LineStyle.DASH); polyline.setLineStyle(LineStyle.DASH);
polyline.setLineWidth(2); polyline.setLineWidth(2);
return connection; return connection;
......
...@@ -95,13 +95,13 @@ public class RelationshipExclusionConstraintPattern extends AbstractInterRelatio ...@@ -95,13 +95,13 @@ public class RelationshipExclusionConstraintPattern extends AbstractInterRelatio
0, -1*ARROWHEAD_HEIGHT };//P3 0, -1*ARROWHEAD_HEIGHT };//P3
Polyline polylineTarget = graphicAlgorithmService.createPolyline(connectionDecoratorTarget, points); Polyline polylineTarget = graphicAlgorithmService.createPolyline(connectionDecoratorTarget, points);
polylineTarget.setLineWidth(2); polylineTarget.setLineWidth(2);
polylineTarget.setForeground(manageColor(COLOR_CONNECTIONS)); polylineTarget.setForeground(manageColor(COLOR_CONSTRAINTS));
PropertyUtil.setShape_IdValue(connectionDecoratorTarget, SHAPE_ID_INTER_REL_CON); PropertyUtil.setShape_IdValue(connectionDecoratorTarget, SHAPE_ID_INTER_REL_CON);
ConnectionDecorator connectionDecoratorSource = ConnectionDecorator connectionDecoratorSource =
pictogramElementCreateService.createConnectionDecorator(connection, false, 0, true); pictogramElementCreateService.createConnectionDecorator(connection, false, 0, true);
Polyline polylineSource = graphicAlgorithmService.createPolyline(connectionDecoratorSource, points); Polyline polylineSource = graphicAlgorithmService.createPolyline(connectionDecoratorSource, points);
polylineSource.setLineWidth(2); polylineSource.setLineWidth(2);
polylineSource.setForeground(manageColor(COLOR_CONNECTIONS)); polylineSource.setForeground(manageColor(COLOR_CONSTRAINTS));
PropertyUtil.setShape_IdValue(connectionDecoratorSource, SHAPE_ID_INTER_REL_CON); PropertyUtil.setShape_IdValue(connectionDecoratorSource, SHAPE_ID_INTER_REL_CON);
//Step 4 //Step 4
link(connection, addedRoleImplication); link(connection, addedRoleImplication);
......
...@@ -94,7 +94,7 @@ public class RelationshipImplicationConstraintPattern extends AbstractInterRelat ...@@ -94,7 +94,7 @@ public class RelationshipImplicationConstraintPattern extends AbstractInterRelat
0, 0, //P2 0, 0, //P2
-1*ARROWHEAD_LENGTH, -1*ARROWHEAD_HEIGHT }; //P3 -1*ARROWHEAD_LENGTH, -1*ARROWHEAD_HEIGHT }; //P3
Polygon arrowhead = graphicAlgorithmService.createPolygon(connectionDecorator, points); Polygon arrowhead = graphicAlgorithmService.createPolygon(connectionDecorator, points);
arrowhead.setForeground(manageColor(COLOR_CONNECTIONS)); arrowhead.setForeground(manageColor(COLOR_CONSTRAINTS));
arrowhead.setBackground(manageColor(COLOR_ARROWHEAD)); arrowhead.setBackground(manageColor(COLOR_ARROWHEAD));
PropertyUtil.setShape_IdValue(connectionDecorator, SHAPE_ID_INTER_REL_CON); PropertyUtil.setShape_IdValue(connectionDecorator, SHAPE_ID_INTER_REL_CON);
//Step 4 //Step 4
......
...@@ -51,7 +51,7 @@ public abstract class AbstractIntraRelationshipConstraintPattern extends FRaMEDS ...@@ -51,7 +51,7 @@ public abstract class AbstractIntraRelationshipConstraintPattern extends FRaMEDS
* the color values gathered from {@link LayoutLiterals} * the color values gathered from {@link LayoutLiterals}
*/ */
protected static final IColorConstant COLOR_CONNECTIONS = LayoutLiterals.COLOR_CONNECTIONS, protected static final IColorConstant COLOR_CONNECTIONS = LayoutLiterals.COLOR_CONNECTIONS,
COLOR_TEXT = LayoutLiterals.COLOR_TEXT; COLOR_CONSTRAINTS = LayoutLiterals.COLOR_CONSTRAINTS;
/** /**
* layout integers gathered from {@link LayoutLiterals} * layout integers gathered from {@link LayoutLiterals}
...@@ -141,8 +141,7 @@ public abstract class AbstractIntraRelationshipConstraintPattern extends FRaMEDS ...@@ -141,8 +141,7 @@ public abstract class AbstractIntraRelationshipConstraintPattern extends FRaMEDS
ConnectionDecorator constraintName = ConnectionDecorator constraintName =
pictogramElementCreateService.createConnectionDecorator(targetConnection, true, 0.5, true); pictogramElementCreateService.createConnectionDecorator(targetConnection, true, 0.5, true);
Text nameText = graphicAlgorithmService.createText(constraintName, type.getName().toLowerCase()); Text nameText = graphicAlgorithmService.createText(constraintName, type.getName().toLowerCase());
nameText.setForeground(manageColor(COLOR_TEXT)); nameText.setForeground(manageColor(COLOR_CONSTRAINTS));
nameText.setFont(manageFont("Arial", 10, false, true));
PropertyUtil.setShape_IdValue(constraintName, SHAPE_ID_INTRA_REL_CON_NAME_DECORATOR); PropertyUtil.setShape_IdValue(constraintName, SHAPE_ID_INTRA_REL_CON_NAME_DECORATOR);
link(constraintName, addContext.getNewObject()); link(constraintName, addContext.getNewObject());
return constraintName; return constraintName;
......
...@@ -86,11 +86,13 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{ ...@@ -86,11 +86,13 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{
*/ */
private PaletteView paletteView = PaletteView.TOPLEVEL_VIEW; private PaletteView paletteView = PaletteView.TOPLEVEL_VIEW;
//TODO /**
PaletteCompartmentEntry entityCategory = new PaletteCompartmentEntry(ENTITIES_PALETTE_CATEGORY_NAME, null); * the categories of the palette
PaletteCompartmentEntry propertiesCategory = new PaletteCompartmentEntry(PROPERTIES_PALETTE_CATEGORY_NAME, null); */
PaletteCompartmentEntry relationsCategory = new PaletteCompartmentEntry(RELATIONS_PALETTE_CATEGORY_NAME, null); PaletteCompartmentEntry entityCategory,
PaletteCompartmentEntry constraintsCategory = new PaletteCompartmentEntry(CONSTRAINTS_PALETTE_CATEGORY_NAME, null); propertiesCategory,
relationsCategory,
constraintsCategory;
/** /**
* Class constructor * Class constructor
...@@ -199,7 +201,11 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{ ...@@ -199,7 +201,11 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{
* builds the palette of the editor using the following steps * builds the palette of the editor using the following steps
* <p> * <p>
* Step 1: It creates the different palette categories.<br> * Step 1: It creates the different palette categories.<br>
* Step 2: It add create shape features to the correct categories according to the {@link FeatureManager} * Step 2: It adds create shape features to the correct categories according to the {@link FeatureManager}
* using the operation {@link #addShapeFeature}.<br>
* Step 3: It adds create connection features to the correct categories according to the {@link FeatureManager}
* using the operation {@link #addConnectionFeature}.<br>
* Step 4: It adds the categories with the added features to the palette.
*/ */
@Override @Override
public IPaletteCompartmentEntry[] getPalette() { public IPaletteCompartmentEntry[] getPalette() {
...@@ -209,12 +215,15 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{ ...@@ -209,12 +215,15 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{
propertiesCategory = new PaletteCompartmentEntry(PROPERTIES_PALETTE_CATEGORY_NAME, null); propertiesCategory = new PaletteCompartmentEntry(PROPERTIES_PALETTE_CATEGORY_NAME, null);
relationsCategory = new PaletteCompartmentEntry(RELATIONS_PALETTE_CATEGORY_NAME, null); relationsCategory = new PaletteCompartmentEntry(RELATIONS_PALETTE_CATEGORY_NAME, null);
constraintsCategory = new PaletteCompartmentEntry(CONSTRAINTS_PALETTE_CATEGORY_NAME, null); constraintsCategory = new PaletteCompartmentEntry(CONSTRAINTS_PALETTE_CATEGORY_NAME, null);
//Step 2
for(ICreateFeature feature : getFeatureProvider().getCreateFeatures()) { for(ICreateFeature feature : getFeatureProvider().getCreateFeatures()) {
addShapeFeature(feature); addShapeFeature(feature);
} }
//Step 3
for(ICreateConnectionFeature feature : getFeatureProvider().getCreateConnectionFeatures()) { for(ICreateConnectionFeature feature : getFeatureProvider().getCreateConnectionFeatures()) {
addConnectionFeature(feature); addConnectionFeature(feature);
} }
//Step 4
pallete.add(entityCategory); pallete.add(entityCategory);
pallete.add(propertiesCategory); pallete.add(propertiesCategory);
pallete.add(relationsCategory); pallete.add(relationsCategory);
...@@ -222,6 +231,13 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{ ...@@ -222,6 +231,13 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{
return pallete.toArray(new IPaletteCompartmentEntry[pallete.size()]); return pallete.toArray(new IPaletteCompartmentEntry[pallete.size()]);
} }
/**
* adds a shape feature to a palette category if wanted
* <p>
* It uses the {@link FeaturePaletteDescriptor} of the feature to calculate if and where to add the
* feature.
* @param feature the feature to probably add to the palette
*/
private void addShapeFeature(ICreateFeature feature) { private void addShapeFeature(ICreateFeature feature) {
FeaturePaletteDescriptor fpd = FeatureManager.features.get(feature.getCreateName()); FeaturePaletteDescriptor fpd = FeatureManager.features.get(feature.getCreateName());
if(fpd == null) throw new FeatureHasNoPaletteDescriptorException(feature.getCreateName()); if(fpd == null) throw new FeatureHasNoPaletteDescriptorException(feature.getCreateName());
...@@ -251,6 +267,13 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{ ...@@ -251,6 +267,13 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{
break; break;
} } } } } }
/**
* adds a connection feature to a palette category if wanted
* <p>
* It uses the {@link FeaturePaletteDescriptor} of the feature to calculate if and where to add the
* feature.
* @param feature the feature to probably add to the palette
*/
private void addConnectionFeature(ICreateConnectionFeature feature) { private void addConnectionFeature(ICreateConnectionFeature feature) {
FeaturePaletteDescriptor fpd = FeatureManager.features.get(feature.getCreateName()); FeaturePaletteDescriptor fpd = FeatureManager.features.get(feature.getCreateName());
if(fpd == null) throw new FeatureHasNoPaletteDescriptorException(feature.getCreateName()); if(fpd == null) throw new FeatureHasNoPaletteDescriptorException(feature.getCreateName());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment