Search in sources :

Example 76 with PointList

use of org.eclipse.draw2d.geometry.PointList in project yamcs-studio by yamcs.

the class ManhattanBendpointEditPolicy method getNewPoints.

/**
 * Get new Points based on bendpoint move request.
 *
 * @param request
 * @return
 */
private PointList getNewPoints(BendpointRequest request) {
    PointList newPoints = getConnection().getPoints().getCopy();
    int aIndex = request.getIndex() + 1;
    Point oldA = newPoints.getPoint(aIndex);
    Point oldB = newPoints.getPoint(aIndex + 1);
    Point newM = request.getLocation().getCopy();
    Point newA, newB;
    getConnection().translateToRelative(newM);
    if (oldA.x == oldB.x) {
        // hozitontal move
        int dx = newM.x - oldA.x;
        newA = oldA.getTranslated(dx, 0);
        newB = oldB.getTranslated(dx, 0);
    } else {
        // vertical move
        int dy = newM.y - oldA.y;
        newA = oldA.getTranslated(0, dy);
        newB = oldB.getTranslated(0, dy);
    }
    newPoints.setPoint(newA, aIndex);
    newPoints.setPoint(newB, aIndex + 1);
    newPoints.removePoint(0);
    newPoints.removePoint(newPoints.size() - 1);
    return newPoints;
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) Point(org.eclipse.draw2d.geometry.Point) Point(org.eclipse.draw2d.geometry.Point)

Example 77 with PointList

use of org.eclipse.draw2d.geometry.PointList in project yamcs-studio by yamcs.

the class WidgetNodeEditPolicy method getReconnectSourceCommand.

@Override
protected Command getReconnectSourceCommand(ReconnectRequest request) {
    ConnectionModel connection = (ConnectionModel) request.getConnectionEditPart().getModel();
    AbstractWidgetModel newSource = getWidgetEditPart().getWidgetModel();
    ConnectionAnchor anchor = getWidgetEditPart().getTargetConnectionAnchor(request);
    String newTerminal = getWidgetEditPart().getTerminalNameFromAnchor(anchor);
    ConnectionReconnectCommand cmd = new ConnectionReconnectCommand(connection);
    cmd.setNewSource(newSource);
    cmd.setNewSourceTerminal(newTerminal);
    // clear point list
    return cmd.chain(new SetWidgetPropertyCommand(connection, ConnectionModel.PROP_POINTS, new PointList()));
}
Also used : SetWidgetPropertyCommand(org.csstudio.opibuilder.commands.SetWidgetPropertyCommand) PointList(org.eclipse.draw2d.geometry.PointList) ConnectionAnchor(org.eclipse.draw2d.ConnectionAnchor) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) ConnectionModel(org.csstudio.opibuilder.model.ConnectionModel) ConnectionReconnectCommand(org.csstudio.opibuilder.commands.ConnectionReconnectCommand)

Example 78 with PointList

use of org.eclipse.draw2d.geometry.PointList in project yamcs-studio by yamcs.

the class AbstractWidgetModel method scaleConnections.

/**
 * @param widthRatio
 * @param heightRatio
 */
protected void scaleConnections(double widthRatio, double heightRatio) {
    for (ConnectionModel conn : getSourceConnections()) {
        if (conn.getPoints() != null && conn.getPoints().size() > 0) {
            PointList pl = conn.getOriginPoints().getCopy();
            for (int i = 0; i < pl.size(); i++) {
                pl.setPoint(new Point((int) Math.round((pl.getPoint(i).x * widthRatio)), (int) Math.round(pl.getPoint(i).y * heightRatio)), i);
            }
            conn.setPoints(pl);
        }
    }
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) Point(org.eclipse.draw2d.geometry.Point) Point(org.eclipse.draw2d.geometry.Point)

Example 79 with PointList

use of org.eclipse.draw2d.geometry.PointList in project yamcs-studio by yamcs.

the class ConnectionModel method configureProperties.

@Override
protected void configureProperties() {
    addProperty(new IntegerProperty(PROP_LINE_WIDTH, "Line Width", WidgetPropertyCategory.Display, 1, 1, 100));
    addProperty(new ComboProperty(PROP_LINE_STYLE, "Line Style", WidgetPropertyCategory.Display, LineStyle.stringValues(), 0));
    addProperty(new ColorProperty(PROP_LINE_COLOR, "Line Color", WidgetPropertyCategory.Display, CustomMediaFactory.COLOR_BLACK));
    addProperty(new ComboProperty(PROP_ROUTER, "Router", WidgetPropertyCategory.Display, RouterType.stringValues(), 0));
    addProperty(new ComboProperty(PROP_ARROW_TYPE, "Arrows", WidgetPropertyCategory.Display, ArrowType.stringValues(), 0));
    addProperty(new BooleanProperty(PROP_FILL_ARROW, "Fill Arrow", WidgetPropertyCategory.Display, true));
    addProperty(new IntegerProperty(PROP_ARROW_LENGTH, "Arrow Length", WidgetPropertyCategory.Display, 15, 5, 1000));
    addProperty(new BooleanProperty(PROP_ANTIALIAS, "Anti Alias", WidgetPropertyCategory.Display, true));
    addProperty(new StringProperty(PROP_SRC_TERM, "Source Terminal", WidgetPropertyCategory.Display, ""));
    addProperty(new StringProperty(PROP_TGT_TERM, "Target Terminal", WidgetPropertyCategory.Display, ""));
    addProperty(new PointListProperty(PROP_POINTS, "Points", WidgetPropertyCategory.Display, new PointList()));
    addProperty(new ComboProperty(PROP_LINE_JUMP_ADD, "Add Line Jump To", WidgetPropertyCategory.Display, LineJumpAdd.stringValues(), 0));
    addProperty(new ComboProperty(PROP_LINE_JUMP_STYLE, "Line Jump Style", WidgetPropertyCategory.Display, LineJumpStyle.stringValues(), 0));
    addProperty(new IntegerProperty(PROP_LINE_JUMP_SIZE, "Line Jump Size", WidgetPropertyCategory.Display, 10, 1, 100));
    AbstractWidgetProperty loadedFromLinkingContainer = new StringProperty(PROP_IS_LOADED_FROM_LINKING_CONTAINER, "Is Loaded From Linking Container", WidgetPropertyCategory.Behavior, "false");
    addProperty(loadedFromLinkingContainer);
    setPropertyVisibleAndSavable(PROP_IS_LOADED_FROM_LINKING_CONTAINER, false, false);
    setPropertyVisibleAndSavable(PROP_POINTS, false, true);
    AbstractWidgetProperty srcWUIDProp = new StringProperty(PROP_SRC_WUID, "Source WUID", WidgetPropertyCategory.Display, "");
    addProperty(srcWUIDProp);
    srcWUIDProp.addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (displayModel == null)
                return;
            String wuid = evt.getNewValue().toString();
            String path = getPropertyValue(PROP_SRC_PATH).toString();
            AbstractWidgetModel w = null;
            if (path == null || path.equals("")) {
                w = getTerminal(displayModel, null, wuid);
            } else {
                List<String> paths = Arrays.asList(path.split(PATH_DELIMITER));
                w = getTerminal(displayModel, paths, wuid);
            }
            if (w != null) {
                source = w;
                reconnect();
            } else
                throw new IllegalArgumentException("Non exist widget PATH:[" + path + "],\nWUID:[" + wuid + "]");
        }
    });
    AbstractWidgetProperty tgtWUIDProp = new StringProperty(PROP_TGT_WUID, "Target WUID", WidgetPropertyCategory.Display, "");
    addProperty(tgtWUIDProp);
    tgtWUIDProp.addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (displayModel == null)
                return;
            String wuid = evt.getNewValue().toString();
            String path = getPropertyValue(PROP_TGT_PATH).toString();
            AbstractWidgetModel w = null;
            if (path == null || path.equals("")) {
                w = getTerminal(displayModel, null, wuid);
            } else {
                List<String> paths = Arrays.asList(path.split(PATH_DELIMITER));
                w = getTerminal(displayModel, paths, wuid);
            }
            if (w != null) {
                target = w;
                reconnect();
            } else
                throw new IllegalArgumentException("Non exist widget PATH:[" + path + "],\nWUID:[" + wuid + "]");
        }
    });
    AbstractWidgetProperty srcPathProp = new StringProperty(PROP_SRC_PATH, "Source Path", WidgetPropertyCategory.Display, "");
    addProperty(srcPathProp);
    AbstractWidgetProperty tgtPathProp = new StringProperty(PROP_TGT_PATH, "Target Path", WidgetPropertyCategory.Display, "");
    addProperty(tgtPathProp);
    setPropertyVisibleAndSavable(PROP_SRC_WUID, false, true);
    setPropertyVisibleAndSavable(PROP_TGT_WUID, false, true);
    setPropertyVisibleAndSavable(PROP_SRC_PATH, false, true);
    setPropertyVisibleAndSavable(PROP_TGT_PATH, false, true);
    setPropertyVisibleAndSavable(PROP_SRC_TERM, false, true);
    setPropertyVisibleAndSavable(PROP_TGT_TERM, false, true);
    removeProperty(PROP_BORDER_COLOR);
    removeProperty(PROP_BORDER_STYLE);
    removeProperty(PROP_BORDER_WIDTH);
    removeProperty(PROP_VISIBLE);
    removeProperty(PROP_ENABLED);
    removeProperty(PROP_TOOLTIP);
    removeProperty(PROP_ACTIONS);
    removeProperty(PROP_FONT);
    removeProperty(PROP_XPOS);
    removeProperty(PROP_YPOS);
    removeProperty(PROP_WIDTH);
    removeProperty(PROP_HEIGHT);
    removeProperty(PROP_RULES);
    removeProperty(PROP_ACTIONS);
    removeProperty(PROP_SCRIPTS);
    removeProperty(PROP_COLOR_BACKGROUND);
    removeProperty(PROP_COLOR_FOREGROUND);
    removeProperty(PROP_SCALE_OPTIONS);
}
Also used : ComboProperty(org.csstudio.opibuilder.properties.ComboProperty) IntegerProperty(org.csstudio.opibuilder.properties.IntegerProperty) PointList(org.eclipse.draw2d.geometry.PointList) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) BooleanProperty(org.csstudio.opibuilder.properties.BooleanProperty) AbstractWidgetProperty(org.csstudio.opibuilder.properties.AbstractWidgetProperty) StringProperty(org.csstudio.opibuilder.properties.StringProperty) PointListProperty(org.csstudio.opibuilder.properties.PointListProperty) PointList(org.eclipse.draw2d.geometry.PointList) List(java.util.List) ColorProperty(org.csstudio.opibuilder.properties.ColorProperty)

Example 80 with PointList

use of org.eclipse.draw2d.geometry.PointList in project yamcs-studio by yamcs.

the class PointListCellEditor method doSetValue.

/**
 * {@inheritDoc}
 */
@Override
protected void doSetValue(final Object value) {
    Assert.isTrue(value instanceof PointList);
    PointList list = (PointList) value;
    _orgPointList = new LinkedList<Point>();
    _pointList = new LinkedList<Point>();
    for (int i = 0; i < list.size(); i++) {
        _pointList.add(list.getPoint(i));
        _orgPointList.add(list.getPoint(i));
    }
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) Point(org.eclipse.draw2d.geometry.Point) Point(org.eclipse.draw2d.geometry.Point)

Aggregations

PointList (org.eclipse.draw2d.geometry.PointList)80 Point (org.eclipse.draw2d.geometry.Point)49 Rectangle (org.eclipse.draw2d.geometry.Rectangle)15 PrecisionPoint (org.eclipse.draw2d.geometry.PrecisionPoint)10 ArrayList (java.util.ArrayList)9 ConnectionModel (org.csstudio.opibuilder.model.ConnectionModel)8 Polyline (org.eclipse.draw2d.Polyline)7 List (java.util.List)6 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)6 AbstractPolyModel (org.csstudio.opibuilder.widgets.model.AbstractPolyModel)5 Dimension (org.eclipse.draw2d.geometry.Dimension)5 Bendpoint (org.eclipse.draw2d.Bendpoint)4 PrecisionRectangle (org.eclipse.draw2d.geometry.PrecisionRectangle)4 SetWidgetPropertyCommand (org.csstudio.opibuilder.commands.SetWidgetPropertyCommand)3 AbstractBaseEditPart (org.csstudio.opibuilder.editparts.AbstractBaseEditPart)3 PolarPoint (org.csstudio.swt.widgets.figureparts.PolarPoint)3 AbsoluteBendpoint (org.eclipse.draw2d.AbsoluteBendpoint)3 PropertyChangeEvent (java.beans.PropertyChangeEvent)2 PropertyChangeListener (java.beans.PropertyChangeListener)2 ConnectionReconnectCommand (org.csstudio.opibuilder.commands.ConnectionReconnectCommand)2