Search in sources :

Example 1 with ITextPosition

use of com.archimatetool.model.ITextPosition in project archi by archimatetool.

the class RectangleFigureDelegate method calculateTextControlBounds.

@Override
public Rectangle calculateTextControlBounds() {
    Rectangle bounds = getBounds();
    if (getOwner().getDiagramModelObject() instanceof ITextPosition) {
        int textpos = ((ITextPosition) getOwner().getDiagramModelObject()).getTextPosition();
        int textAlignment = getOwner().getDiagramModelObject().getTextAlignment();
        if (textpos == ITextPosition.TEXT_POSITION_TOP) {
            if (textAlignment == ITextAlignment.TEXT_ALIGNMENT_CENTER) {
                bounds.x += iconOffset;
                bounds.width = bounds.width - (iconOffset * 2);
            } else if (textAlignment == ITextAlignment.TEXT_ALIGNMENT_RIGHT) {
                bounds.width -= iconOffset;
            }
        }
    }
    return bounds;
}
Also used : ITextPosition(com.archimatetool.model.ITextPosition) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 2 with ITextPosition

use of com.archimatetool.model.ITextPosition in project archi by archimatetool.

the class AbstractTextControlContainerFigure method createTextFlowControl.

protected TextFlow createTextFlowControl(Locator textLocator) {
    TextFlow textFlow = new TextFlow();
    int wordWrapStyle = Preferences.STORE.getInt(IPreferenceConstants.ARCHIMATE_FIGURE_WORD_WRAP_STYLE);
    textFlow.setLayoutManager(new ParagraphTextLayout(textFlow, wordWrapStyle));
    BlockFlow block = new BlockFlow();
    block.add(textFlow);
    FlowPage page = new FlowPage();
    page.add(block);
    Figure textWrapperFigure = new Figure();
    GridLayout layout = new GridLayout();
    layout.marginWidth = getTextControlMarginWidth();
    layout.marginHeight = 5;
    textWrapperFigure.setLayoutManager(layout);
    GridData gd = new GridData(SWT.CENTER, SWT.TOP, true, true);
    textWrapperFigure.add(page, gd);
    if (getDiagramModelObject() instanceof ITextPosition) {
        fTextPositionDelegate = new TextPositionDelegate(textWrapperFigure, page, (ITextPosition) getDiagramModelObject());
    }
    add(textWrapperFigure, textLocator);
    return textFlow;
}
Also used : FlowPage(org.eclipse.draw2d.text.FlowPage) GridLayout(org.eclipse.draw2d.GridLayout) ITextPosition(com.archimatetool.model.ITextPosition) BlockFlow(org.eclipse.draw2d.text.BlockFlow) GridData(org.eclipse.draw2d.GridData) TextFlow(org.eclipse.draw2d.text.TextFlow) ParagraphTextLayout(org.eclipse.draw2d.text.ParagraphTextLayout) IFigure(org.eclipse.draw2d.IFigure) Figure(org.eclipse.draw2d.Figure)

Example 3 with ITextPosition

use of com.archimatetool.model.ITextPosition in project archi by archimatetool.

the class AbstractTextControlContainerFigure method calculateTextControlBounds.

/**
 * Calculate the Text Control Bounds or null if none.
 */
protected Rectangle calculateTextControlBounds() {
    // Delegate
    if (getFigureDelegate() != null) {
        return getFigureDelegate().calculateTextControlBounds();
    }
    // If there is no icon we don't need to do any offsets
    if (getIconOffset() == 0) {
        return null;
    }
    Rectangle bounds = getBounds().getCopy();
    // Adjust for left/right margin
    int iconOffset = getIconOffset() - getTextControlMarginWidth();
    int textpos = ((ITextPosition) getDiagramModelObject()).getTextPosition();
    int textAlignment = getDiagramModelObject().getTextAlignment();
    if (textpos == ITextPosition.TEXT_POSITION_TOP) {
        if (textAlignment == ITextAlignment.TEXT_ALIGNMENT_CENTER) {
            bounds.x += iconOffset;
            bounds.width = bounds.width - (iconOffset * 2);
        } else if (textAlignment == ITextAlignment.TEXT_ALIGNMENT_RIGHT) {
            bounds.width -= iconOffset;
        }
    }
    return bounds;
}
Also used : ITextPosition(com.archimatetool.model.ITextPosition) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 4 with ITextPosition

use of com.archimatetool.model.ITextPosition in project archi by archimatetool.

the class FormatPainterTool method createCommand.

protected CompoundCommand createCommand(PaintFormat pf, IDiagramModelComponent targetComponent) {
    CompoundCommand result = new CompoundCommand(Messages.FormatPainterTool_0);
    // IFontAttribute
    if (pf.getSourceComponent() instanceof IFontAttribute && targetComponent instanceof IFontAttribute) {
        IFontAttribute source = (IFontAttribute) pf.getSourceComponent();
        IFontAttribute target = (IFontAttribute) targetComponent;
        Command cmd = new FontStyleCommand(target, source.getFont());
        if (cmd.canExecute()) {
            result.add(cmd);
        }
        cmd = new FontColorCommand(target, source.getFontColor());
        if (cmd.canExecute()) {
            result.add(cmd);
        }
    }
    // ILineObject
    if (pf.getSourceComponent() instanceof ILineObject && targetComponent instanceof ILineObject) {
        ILineObject source = (ILineObject) pf.getSourceComponent();
        ILineObject target = (ILineObject) targetComponent;
        Command cmd = new LineColorCommand(target, source.getLineColor());
        if (cmd.canExecute()) {
            result.add(cmd);
        }
        cmd = new LineWidthCommand(target, source.getLineWidth());
        if (cmd.canExecute()) {
            result.add(cmd);
        }
    }
    // IBorderObject
    if (pf.getSourceComponent() instanceof IBorderObject && targetComponent instanceof IBorderObject) {
        IBorderObject source = (IBorderObject) pf.getSourceComponent();
        IBorderObject target = (IBorderObject) targetComponent;
        Command cmd = new BorderColorCommand(target, source.getBorderColor());
        if (cmd.canExecute()) {
            result.add(cmd);
        }
    }
    // ITextPosition
    if (pf.getSourceComponent() instanceof ITextPosition && targetComponent instanceof ITextPosition) {
        ITextPosition source = (ITextPosition) pf.getSourceComponent();
        ITextPosition target = (ITextPosition) targetComponent;
        Command cmd = new TextPositionCommand(target, source.getTextPosition());
        if (cmd.canExecute()) {
            result.add(cmd);
        }
    }
    // ITextAlignment
    if (pf.getSourceComponent() instanceof ITextAlignment && targetComponent instanceof ITextAlignment) {
        ITextAlignment source = (ITextAlignment) pf.getSourceComponent();
        ITextAlignment target = (ITextAlignment) targetComponent;
        Command cmd = new TextAlignmentCommand(target, source.getTextAlignment());
        if (cmd.canExecute()) {
            result.add(cmd);
        }
    }
    // IDiagramModelObject
    if (pf.getSourceComponent() instanceof IDiagramModelObject && targetComponent instanceof IDiagramModelObject) {
        IDiagramModelObject source = (IDiagramModelObject) pf.getSourceComponent();
        IDiagramModelObject target = (IDiagramModelObject) targetComponent;
        // Source fill colour is null which is "default"
        String fillColorString = source.getFillColor();
        if (fillColorString == null) {
            fillColorString = ColorFactory.convertColorToString(ColorFactory.getDefaultFillColor(source));
        }
        Command cmd = new FillColorCommand(target, fillColorString);
        if (cmd.canExecute()) {
            result.add(cmd);
        }
        // Alpha opacity
        cmd = new DiagramModelObjectAlphaCommand(target, source.getAlpha());
        if (cmd.canExecute()) {
            result.add(cmd);
        }
    }
    // IDiagramModelConnection
    if (pf.getSourceComponent() instanceof IDiagramModelConnection && targetComponent instanceof IDiagramModelConnection) {
        IDiagramModelConnection source = (IDiagramModelConnection) pf.getSourceComponent();
        IDiagramModelConnection target = (IDiagramModelConnection) targetComponent;
        // Connection text position
        Command cmd = new ConnectionTextPositionCommand(target, source.getTextPosition());
        if (cmd.canExecute()) {
            result.add(cmd);
        }
    }
    return result;
}
Also used : TextAlignmentCommand(com.archimatetool.editor.diagram.commands.TextAlignmentCommand) LineColorCommand(com.archimatetool.editor.diagram.commands.LineColorCommand) ITextPosition(com.archimatetool.model.ITextPosition) FillColorCommand(com.archimatetool.editor.diagram.commands.FillColorCommand) IDiagramModelConnection(com.archimatetool.model.IDiagramModelConnection) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) DiagramModelObjectAlphaCommand(com.archimatetool.editor.diagram.commands.DiagramModelObjectAlphaCommand) ILineObject(com.archimatetool.model.ILineObject) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) BorderColorCommand(com.archimatetool.editor.diagram.commands.BorderColorCommand) IBorderObject(com.archimatetool.model.IBorderObject) FontColorCommand(com.archimatetool.editor.diagram.commands.FontColorCommand) ITextAlignment(com.archimatetool.model.ITextAlignment) FontStyleCommand(com.archimatetool.editor.diagram.commands.FontStyleCommand) DiagramModelObjectAlphaCommand(com.archimatetool.editor.diagram.commands.DiagramModelObjectAlphaCommand) ConnectionTextPositionCommand(com.archimatetool.editor.diagram.commands.ConnectionTextPositionCommand) BorderColorCommand(com.archimatetool.editor.diagram.commands.BorderColorCommand) TextPositionCommand(com.archimatetool.editor.diagram.commands.TextPositionCommand) LineWidthCommand(com.archimatetool.editor.diagram.commands.LineWidthCommand) FontColorCommand(com.archimatetool.editor.diagram.commands.FontColorCommand) TextAlignmentCommand(com.archimatetool.editor.diagram.commands.TextAlignmentCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) FillColorCommand(com.archimatetool.editor.diagram.commands.FillColorCommand) LineColorCommand(com.archimatetool.editor.diagram.commands.LineColorCommand) Command(org.eclipse.gef.commands.Command) IFontAttribute(com.archimatetool.model.IFontAttribute) ConnectionTextPositionCommand(com.archimatetool.editor.diagram.commands.ConnectionTextPositionCommand) TextPositionCommand(com.archimatetool.editor.diagram.commands.TextPositionCommand) LineWidthCommand(com.archimatetool.editor.diagram.commands.LineWidthCommand) FontStyleCommand(com.archimatetool.editor.diagram.commands.FontStyleCommand) ConnectionTextPositionCommand(com.archimatetool.editor.diagram.commands.ConnectionTextPositionCommand)

Example 5 with ITextPosition

use of com.archimatetool.model.ITextPosition in project archi by archimatetool.

the class BoxFigureDelegate method calculateTextControlBounds.

@Override
public Rectangle calculateTextControlBounds() {
    Rectangle bounds = getBounds();
    int offset = FOLD_HEIGHT + 1;
    int textpos = ((ITextPosition) getOwner().getDiagramModelObject()).getTextPosition();
    int textAlignment = getOwner().getDiagramModelObject().getTextAlignment();
    if (textpos == ITextPosition.TEXT_POSITION_TOP) {
        bounds.y += FOLD_HEIGHT;
        if (textAlignment == ITextAlignment.TEXT_ALIGNMENT_CENTER) {
            bounds.x += iconOffset;
            bounds.width = bounds.width - (iconOffset * 2) - offset;
        } else if (textAlignment == ITextAlignment.TEXT_ALIGNMENT_RIGHT) {
            bounds.width -= offset + iconOffset;
        }
    } else {
        if (textAlignment == ITextAlignment.TEXT_ALIGNMENT_RIGHT) {
            bounds.width -= offset;
        }
    }
    return bounds;
}
Also used : ITextPosition(com.archimatetool.model.ITextPosition) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Aggregations

ITextPosition (com.archimatetool.model.ITextPosition)8 Rectangle (org.eclipse.draw2d.geometry.Rectangle)4 TextPositionCommand (com.archimatetool.editor.diagram.commands.TextPositionCommand)2 Command (org.eclipse.gef.commands.Command)2 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)2 BorderColorCommand (com.archimatetool.editor.diagram.commands.BorderColorCommand)1 ConnectionTextPositionCommand (com.archimatetool.editor.diagram.commands.ConnectionTextPositionCommand)1 DiagramModelObjectAlphaCommand (com.archimatetool.editor.diagram.commands.DiagramModelObjectAlphaCommand)1 FillColorCommand (com.archimatetool.editor.diagram.commands.FillColorCommand)1 FontColorCommand (com.archimatetool.editor.diagram.commands.FontColorCommand)1 FontStyleCommand (com.archimatetool.editor.diagram.commands.FontStyleCommand)1 LineColorCommand (com.archimatetool.editor.diagram.commands.LineColorCommand)1 LineWidthCommand (com.archimatetool.editor.diagram.commands.LineWidthCommand)1 TextAlignmentCommand (com.archimatetool.editor.diagram.commands.TextAlignmentCommand)1 IBorderObject (com.archimatetool.model.IBorderObject)1 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)1 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)1 IFontAttribute (com.archimatetool.model.IFontAttribute)1 ILineObject (com.archimatetool.model.ILineObject)1 ITextAlignment (com.archimatetool.model.ITextAlignment)1