use of com.ramussoft.pb.idef.visual.MovingText in project ramus by Vitaliy-Yakovchuk.
the class ArrowPainter method paintTilda.
public void paintTilda(final Graphics2D g, final PaintSector sector) {
g.setStroke(ArrowPainter.THIN_STROKE);
final MovingText movingText = sector.getText();
final FloatPoint t = sector.getTildaPoint();
final double x1 = movingArea.getIDoubleOrdinate(t.getX());
final double y1 = movingArea.getIDoubleOrdinate(t.getY());
final double x2 = movingArea.getIDoubleOrdinate(movingText.getBounds().getLocation().getX());
final double y2 = movingArea.getIDoubleOrdinate(movingText.getBounds().getLocation().getY());
final double x3 = x2 + movingArea.getIDoubleOrdinate(movingText.getRealWidth());
final double y3 = y2 + movingArea.getIDoubleOrdinate(movingText.getRealHeight());
double lw = 1;
if (sector.getStroke() instanceof BasicStroke)
lw = ((BasicStroke) sector.getStroke()).getLineWidth();
double w = movingArea.getIDoubleOrdinate(lw * 1.5);
double minW = movingArea.getIDoubleOrdinate(2);
if (w < minW)
w = minW;
paintTilda(g, x1, y1, x2, y2, x3, y3, w, movingArea);
}
use of com.ramussoft.pb.idef.visual.MovingText in project ramus by Vitaliy-Yakovchuk.
the class PaintSector method getTildaOPoint.
public FloatPoint getTildaOPoint() {
final MovingText movingText = getText();
final double x2 = movingArea.getIDoubleOrdinate(movingText.getBounds().getLocation().getX());
final double y2 = movingArea.getIDoubleOrdinate(movingText.getBounds().getLocation().getY());
final double x3 = x2 + movingArea.getIDoubleOrdinate(movingText.getBounds().getWidth());
final double y3 = y2 + movingArea.getIDoubleOrdinate(movingText.getBounds().getHeight());
double x = getTildaPoint().getX();
double y = getTildaPoint().getY();
if (x3 < x)
x = x3;
else if (x2 > x)
x = x2;
if (y3 < y)
y = y3;
else if (y2 > y)
y = y2;
final FloatPoint fp = new FloatPoint(x, y);
return fp;
}
use of com.ramussoft.pb.idef.visual.MovingText in project ramus by Vitaliy-Yakovchuk.
the class SectorRefactor method updatePageSize.
public void updatePageSize(boolean updateFonts, boolean updateZoom, double percent, Function function) {
if (updateZoom) {
function.setBounds(function.getBounds().zoom(percent));
}
if (updateFonts) {
Font font = function.getFont();
if (font != null) {
function.setFont(new Font(font.getName(), font.getStyle(), (int) (font.getSize() * percent)));
}
}
if (function.getChildCount() == 0)
return;
if (updateZoom) {
loadFromFunction(function, false);
for (MovingText text : texts) {
if (text instanceof IDEF0Object) {
} else {
// text.setBounds(text.getBounds().zoom(percent));
}
}
HashSet<Ordinate> ordinates = new HashSet<Ordinate>();
for (PaintSector paintSector : sectors) {
for (int i = 0; i < paintSector.getPointCount(); i++) {
Point point = paintSector.getPoint(i);
if (!ordinates.contains(point.getXOrdinate()))
ordinates.add(point.getXOrdinate());
if (!ordinates.contains(point.getYOrdinate()))
ordinates.add(point.getYOrdinate());
}
MovingLabel movingLabel = paintSector.getText();
if (movingLabel != null) {
movingLabel.setBounds(movingLabel.getBounds().zoom(percent));
Font font = movingLabel.getFont();
movingLabel.setFont(new Font(font.getName(), font.getStyle(), (int) (font.getSize() * percent)));
}
Font font = paintSector.getFont();
if (font != null) {
paintSector.setFont(new Font(font.getName(), font.getStyle(), (int) (font.getSize() * percent)));
paintSector.saveVisual();
}
}
for (Ordinate o : ordinates) {
o.setPosition(percent * o.getPosition());
}
for (PaintSector paintSector : sectors) {
for (int i = 0; i < paintSector.getPointCount(); i++) {
if (paintSector.getSector().getEnd().getBorderType() == Point.BOTTOM) {
Point point = paintSector.getEndPoint();
point.getYOrdinate().setPosition(movingArea.CLIENT_HEIGHT - 7);
} else if (paintSector.getSector().getStart().getBorderType() == Point.BOTTOM) {
Point point = paintSector.getStartPoint();
point.getYOrdinate().setPosition(movingArea.CLIENT_HEIGHT - 7);
}
if (paintSector.getSector().getEnd().getBorderType() == Point.TOP) {
Point point = paintSector.getEndPoint();
point.getYOrdinate().setPosition(7);
} else if (paintSector.getSector().getStart().getBorderType() == Point.TOP) {
Point point = paintSector.getStartPoint();
point.getYOrdinate().setPosition(7);
}
if (paintSector.getSector().getEnd().getBorderType() == Point.LEFT) {
Point point = paintSector.getEndPoint();
point.getXOrdinate().setPosition(7);
} else if (paintSector.getSector().getStart().getBorderType() == Point.LEFT) {
Point point = paintSector.getStartPoint();
point.getXOrdinate().setPosition(7);
}
if (paintSector.getSector().getEnd().getBorderType() == Point.RIGHT) {
Point point = paintSector.getEndPoint();
point.getXOrdinate().setPosition(movingArea.CLIENT_WIDTH - 7);
} else if (paintSector.getSector().getStart().getBorderType() == Point.RIGHT) {
Point point = paintSector.getStartPoint();
point.getXOrdinate().setPosition(movingArea.CLIENT_WIDTH - 7);
}
}
}
saveToFunction();
}
}
use of com.ramussoft.pb.idef.visual.MovingText in project ramus by Vitaliy-Yakovchuk.
the class SectorRefactor method loadFromFunction.
/**
* Метод, який завантажує секторну структуру функціонального блоку, якщо
* інформація вже раніше була завантажена з функціонального блоку, то вона
* автоматично в нього зберігається.
*
* @param function Функціональний блок, з якого завантажаться дані.
* @param save Параметр, який вказує, чи зберігати останню завантажену
* функцію.
*/
public void loadFromFunction(final Function function, final boolean save) {
if (save && this.function != null)
saveToFunction(this.function);
sectors.clear();
texts.clear();
this.function = function;
if (function == null)
return;
((NFunction) function).clearSectorsBuffer();
final byte[] bs = function.getSectorData();
if (bs == null)
return;
final ByteArrayInputStream in = new ByteArrayInputStream(bs);
try {
final DataLoader.MemoryData memoryData = new DataLoader.MemoryData();
// read version
final int ver = DataLoader.readInteger(in);
this.loadVersion = ver;
if (ver < 2 && ver > 0) {
int n = DataLoader.readInteger(in);
for (int i = 0; i < n; i++) {
final PaintSector sector = PaintSector.loadFromStream(in, ver, movingArea, memoryData, getDataPlugin());
if (sector != null)
addSector(sector);
}
} else {
for (Sector sector : function.getSectors()) {
final PaintSector paintSector = PaintSector.loadFromSector(ver, movingArea, memoryData, getDataPlugin(), sector);
if (paintSector != null) {
if (sector.getCreateState() == Sector.STATE_IN)
createInPaintPart(sector);
else if (sector.getCreateState() == Sector.STATE_OUT)
createOutPaintPart(sector);
else
addSector(paintSector);
}
}
}
int n = DataLoader.readInteger(in);
for (int i = 0; i < n; i++) {
final MovingText text = movingArea.createText();
text.setFont(DataLoader.readFont(in, memoryData));
text.setColor(DataLoader.readColor(in, memoryData));
text.setBounds(DataLoader.readFRectangle(in));
text.setText(DataLoader.readString(in));
texts.add(text);
}
in.close();
HashSet<PaintSector> hashSet = new HashSet<PaintSector>();
for (int i = 0; i < getSectorsCount(); i++) {
getSector(i).createTexts(hashSet);
}
} catch (final IOException e) {
e.printStackTrace();
}
}
use of com.ramussoft.pb.idef.visual.MovingText in project ramus by Vitaliy-Yakovchuk.
the class IDEFPanel method getEnableActions.
@Override
public String[] getEnableActions() {
if (actionDisable)
return new String[] {};
final Vector<String> res = new Vector<String>();
res.add(MainFrame.PRINT_PREVIEW);
res.add(MainFrame.PRINT);
res.add(MainFrame.PAGE_SETUP);
res.add(MainFrame.IDEF0_NET);
res.add(MainFrame.GO_TO_PARENT);
res.add(MainFrame.GO_TO_CHILD);
res.add(MainFrame.EXPORT_TO_IMAGES);
if (!isReadOnly()) {
if (movingArea.getActiveFunction() != null && movingArea.getActiveFunction().getChildCount() > 0) {
res.add(MainFrame.CENTER_ALL_SECTORS);
}
if (undoMeneger != null) {
if (undoMeneger.canUndo())
res.add(MainFrame.IDEF0_UNDO);
if (undoMeneger.canRedo())
res.add(MainFrame.IDEF0_REDO);
}
res.add(MainFrame.ADD_MODEL_TO_TEMPLATE);
res.add(MainFrame.MODEL_PROPETIES);
res.add(MainFrame.DIAGRAM_PROPETIES);
res.add(MainFrame.CREATE_LEVEL);
res.add(MainFrame.CURSOR_TOOL);
res.add(MainFrame.FUNCTION_TOOL);
res.add(MainFrame.ARROW_TOOL);
res.add(MainFrame.TILDA_TOOL);
res.add(MainFrame.TEXT_TOOL);
res.add(MainFrame.RELOAD_SAVE);
if ((movingArea.getActiveFunction()).getDecompositionType() == MovingArea.DIAGRAM_TYPE_DFD) {
res.add(MainFrame.EXTERNAL_REFERENCE_TOOL);
res.add(MainFrame.DATA_STORE_TOOL);
for (AbstractButton ab : frame.getDfdsButtons()) {
if (ab.isSelected())
movingArea.cancelAdding();
ab.setVisible(false);
}
for (AbstractButton ab : frame.getDfdButtons()) ab.setVisible(true);
} else if ((movingArea.getActiveFunction()).getDecompositionType() == MovingArea.DIAGRAM_TYPE_DFDS) {
res.add(MainFrame.DFDS_ROLE_TOOL);
for (AbstractButton ab : frame.getDfdButtons()) {
if (ab.isSelected())
movingArea.cancelAdding();
ab.setVisible(false);
}
for (AbstractButton ab : frame.getDfdsButtons()) ab.setVisible(true);
} else {
for (AbstractButton ab : frame.getDfdButtons()) {
if (ab.isSelected())
movingArea.cancelAdding();
ab.setVisible(false);
}
for (AbstractButton ab : frame.getDfdsButtons()) {
if (ab.isSelected())
movingArea.cancelAdding();
ab.setVisible(false);
}
}
if (movingArea.getActiveObject() instanceof PaintSector.Pin) {
res.add(MainFrame.SET_LOOK_FOR_CHILDRENS);
res.add(MainFrame.SET_LOOK_FOR_CHILDRENS_BACKGROUND);
res.add(MainFrame.SET_LOOK_FOR_CHILDRENS_FONT);
res.add(MainFrame.SET_LOOK_FOR_CHILDRENS_FOREGROUND);
res.add(MainFrame.REMOVE);
final PaintSector.Pin pin = (PaintSector.Pin) movingArea.getActiveObject();
if (pin.getSector().getStream() != null && pin.getSector().getStream().getAdded().length > 0)
res.add(MainFrame.ARROW_COPY_VISUAL);
if (pin.getSector().getText() != null) {
res.add(MainFrame.SET_ARROW_TILDA);
getJCheckBoxMenuItem().setSelected(pin.getSector().isShowTilda());
res.add(MainFrame.SET_TRANSPARENT_ARROW_TEXT);
getJCheckBoxMenuItem1().setSelected(pin.getSector().isTransparent());
}
if (pin.getSector().isSelStart() && pin.getSector().getStartTunnelType() != Crosspoint.TUNNEL_NONE || pin.getSector().isSelEnd() && pin.getSector().getEndTunnelType() != Crosspoint.TUNNEL_NONE)
res.add(MainFrame.TUNNEL_ARROW);
res.add(MainFrame.EDIT);
} else if (movingArea.getActiveObject() instanceof MovingFunction) {
final Function function = ((MovingFunction) movingArea.getActiveObject()).getFunction();
if (function.isRemoveable())
res.add(MainFrame.REMOVE);
addParalelActions(res, function);
res.add(MainFrame.FUNCTION_TYPE);
res.add(MainFrame.FUNCTION_TYPE_ACTION);
res.add(MainFrame.FUNCTION_TYPE_OPERATION);
res.add(MainFrame.FUNCTION_TYPE_KOMPLEX);
res.add(MainFrame.FUNCTION_TYPE_PROCESS);
res.add(MainFrame.FUNCTION_TYPE_PROCESS_PART);
res.add(MainFrame.RENAME);
res.add(MainFrame.COPY);
res.add(MainFrame.CUT);
switch(function.getType()) {
case Function.TYPE_ACTION:
{
getJRadioButtonMenuItemAction().setSelected(true);
frame.getJMenuItemAction().setSelected(true);
}
break;
case Function.TYPE_OPERATION:
{
getJRadioButtonMenuItemOperation().setSelected(true);
frame.getJMenuItemOperation().setSelected(true);
}
break;
case Function.TYPE_PROCESS_PART:
{
getJRadioButtonMenuItemProcessPart().setSelected(true);
frame.getJMenuItemProcessPart().setSelected(true);
}
break;
case Function.TYPE_PROCESS:
{
getJRadioButtonMenuItemProcess().setSelected(true);
frame.getJMenuItemProcess().setSelected(true);
}
break;
case Function.TYPE_PROCESS_KOMPLEX:
{
getJRadioButtonMenuItemKomplex().setSelected(true);
frame.getJMenuItemKomplex().setSelected(true);
}
break;
}
res.add(MainFrame.CENTER_ADDED_SECTORS);
final boolean b = !dataPlugin.getBaseFunction().equals(function.getParentRow());
if (b)
res.add(MainFrame.FUNCTION_MOVE);
res.add(MainFrame.FUNCTION_ADD_LEVEL);
res.add(MainFrame.FUNCTION_REMOVE_LEVEL);
res.add(MainFrame.SET_LOOK_FOR_CHILDRENS);
res.add(MainFrame.SET_LOOK_FOR_CHILDRENS_BACKGROUND);
res.add(MainFrame.SET_LOOK_FOR_CHILDRENS_FONT);
res.add(MainFrame.SET_LOOK_FOR_CHILDRENS_FOREGROUND);
res.add(MainFrame.FUNCTION_ADD_LEVEL);
if (function.getChildCount() > 0) {
res.add(MainFrame.OPEN_TAB);
res.add(MainFrame.OPEN_IN_INNER_TAB);
}
res.add(MainFrame.EDIT);
} else if (movingArea.getActiveObject() instanceof MovingText) {
if (!(movingArea.getActiveObject() instanceof MovingLabel))
res.add(MainFrame.EDIT);
if (movingArea.canRenameActive())
res.add(MainFrame.RENAME);
res.add(MainFrame.REMOVE);
if (movingArea.getActiveObject() instanceof DFDSRole) {
if (((DFDSRole) movingArea.getActiveObject()).getFunction().getOwner() != null)
res.add(MainFrame.BRAKE_DFDSROLE_CONNECTION);
res.add(MainFrame.DFDS_ROLE_COPY_VISUAL);
}
} else
res.add(MainFrame.PASTE);
if (getMovingArea().getMouseSelection() != null) {
if (getMovingArea().getMouseSelection().getFunctions().size() > 0) {
res.add(MainFrame.REMOVE);
res.add(MainFrame.COPY);
res.add(MainFrame.CUT);
res.add(MainFrame.VISUAL_OPTIONS);
}
if (getMovingArea().getMouseSelection().getLabels().size() > 1)
res.add(MainFrame.JOIN_ARROWS);
}
}
return res.toArray(new String[res.size()]);
}
Aggregations