Search in sources :

Example 1 with Shape

use of org.freeplane.features.link.ConnectorModel.Shape in project freeplane by freeplane.

the class LinkController method getStandardConnectorShape.

public Shape getStandardConnectorShape() {
    final String standardShape = ResourceController.getResourceController().getProperty(RESOURCES_CONNECTOR_SHAPE);
    final Shape shape = Shape.valueOf(standardShape);
    return shape;
}
Also used : Shape(org.freeplane.features.link.ConnectorModel.Shape)

Example 2 with Shape

use of org.freeplane.features.link.ConnectorModel.Shape in project freeplane by freeplane.

the class MMapMouseListener method mousePressed.

public void mousePressed(final MouseEvent e) {
    super.mousePressed(e);
    if (e.isPopupTrigger())
        return;
    final MapView mapView = (MapView) e.getComponent();
    final Object object = mapView.detectCollision(new Point(originX, originY));
    if (object instanceof ConnectorModel) {
        final ConnectorModel arrowLinkModel = (ConnectorModel) object;
        final Shape shape = arrowLinkModel.getShape();
        if (Shape.EDGE_LIKE.equals(shape) || Shape.LINE.equals(shape) && !arrowLinkModel.isSelfLink()) {
            return;
        }
        draggedLink = arrowLinkModel;
        draggedLinkOldStartPoint = draggedLink.getStartInclination();
        draggedLinkOldEndPoint = draggedLink.getEndInclination();
        draggedLink.setShowControlPoints(true);
        mapView.repaintVisible();
    }
}
Also used : Shape(org.freeplane.features.link.ConnectorModel.Shape) ConnectorModel(org.freeplane.features.link.ConnectorModel) MapView(org.freeplane.view.swing.map.MapView) Point(java.awt.Point)

Example 3 with Shape

use of org.freeplane.features.link.ConnectorModel.Shape in project freeplane by freeplane.

the class MLinkController method setShape.

public void setShape(final ConnectorModel connector, final Shape shape) {
    final Shape oldShape = connector.getShape();
    if (oldShape.equals(shape)) {
        return;
    }
    final IActor actor = new IActor() {

        public void act() {
            connector.setShape(shape);
            final NodeModel node = connector.getSource();
            fireNodeConnectorChange(node, connector);
        }

        public String getDescription() {
            return "setConnectorShape";
        }

        public void undo() {
            connector.setShape(oldShape);
            final NodeModel node = connector.getSource();
            fireNodeConnectorChange(node, connector);
        }
    };
    Controller.getCurrentModeController().execute(actor, connector.getSource().getMap());
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) Shape(org.freeplane.features.link.ConnectorModel.Shape) IActor(org.freeplane.core.undo.IActor)

Example 4 with Shape

use of org.freeplane.features.link.ConnectorModel.Shape in project freeplane by freeplane.

the class LinkBuilder method save.

public void save(final ITreeWriter writer, final ConnectorModel model) throws IOException {
    final NodeModel target = model.getTarget();
    if (target == null) {
        return;
    }
    final XMLElement arrowLink = new XMLElement();
    arrowLink.setName("arrowlink");
    final Shape shape = model.getShape();
    arrowLink.setAttribute("SHAPE", shape.toString());
    final Color color = model.getColor();
    arrowLink.setAttribute("COLOR", ColorUtils.colorToString(color));
    final int width = model.getWidth();
    arrowLink.setAttribute("WIDTH", Integer.toString(width));
    final int alpha = model.getAlpha();
    arrowLink.setAttribute("TRANSPARENCY", Integer.toString(alpha));
    final int[] dash = model.getDash();
    if (dash != null) {
        StringBuilder sb = null;
        for (int i : dash) {
            if (sb == null) {
                sb = new StringBuilder(dash.length * 4);
            } else {
                sb.append(' ');
            }
            sb.append(i);
        }
        if (sb != null) {
            arrowLink.setAttribute("DASH", sb.toString());
        }
    }
    final int fontSize = model.getLabelFontSize();
    arrowLink.setAttribute("FONT_SIZE", Integer.toString(fontSize));
    final String fontFamily = model.getLabelFontFamily();
    arrowLink.setAttribute("FONT_FAMILY", fontFamily);
    final String destinationLabel = target.createID();
    if (destinationLabel != null) {
        arrowLink.setAttribute("DESTINATION", destinationLabel);
    }
    final String sourceLabel = model.getSourceLabel();
    if (sourceLabel != null) {
        arrowLink.setAttribute("SOURCE_LABEL", sourceLabel);
    }
    final String targetLabel = model.getTargetLabel();
    if (targetLabel != null) {
        arrowLink.setAttribute("TARGET_LABEL", targetLabel);
    }
    final String middleLabel = model.getMiddleLabel();
    if (middleLabel != null) {
        arrowLink.setAttribute("MIDDLE_LABEL", middleLabel);
    }
    final Point startInclination = model.getStartInclination();
    if (startInclination != null) {
        arrowLink.setAttribute("STARTINCLINATION", TreeXmlWriter.PointToXml(startInclination));
    }
    final Point endInclination = model.getEndInclination();
    if (endInclination != null) {
        arrowLink.setAttribute("ENDINCLINATION", TreeXmlWriter.PointToXml(endInclination));
    }
    final String startArrow = model.getStartArrow().toString();
    if (startArrow != null) {
        arrowLink.setAttribute("STARTARROW", startArrow);
    }
    final String endArrow = model.getEndArrow().toString();
    if (endArrow != null) {
        arrowLink.setAttribute("ENDARROW", endArrow);
    }
    writer.addElement(model, arrowLink);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) Shape(org.freeplane.features.link.ConnectorModel.Shape) Color(java.awt.Color) Point(java.awt.Point) XMLElement(org.freeplane.n3.nanoxml.XMLElement) Point(java.awt.Point)

Aggregations

Shape (org.freeplane.features.link.ConnectorModel.Shape)4 Point (java.awt.Point)2 NodeModel (org.freeplane.features.map.NodeModel)2 Color (java.awt.Color)1 IActor (org.freeplane.core.undo.IActor)1 ConnectorModel (org.freeplane.features.link.ConnectorModel)1 XMLElement (org.freeplane.n3.nanoxml.XMLElement)1 MapView (org.freeplane.view.swing.map.MapView)1