use of com.ramussoft.pb.Function in project ramus by Vitaliy-Yakovchuk.
the class SectorRefactor method fixEndOwners.
private static void fixEndOwners(Sector sector, DataPlugin dataPlugin) {
Function function2 = sector.getStart().getFunction();
if (function2 != null && function2.getType() == Function.TYPE_DFDS_ROLE)
fillFromOwners(function2, dataPlugin);
Crosspoint crosspoint = sector.getEnd().getCrosspoint();
if (crosspoint != null) {
for (Sector sector2 : crosspoint.getOppozite(sector)) fixEndOwners(sector2, dataPlugin);
}
}
use of com.ramussoft.pb.Function in project ramus by Vitaliy-Yakovchuk.
the class Point method isMoveableFunctionPoint.
/**
* Метод перевіряє, чи можливе переміщення саме цієї точки, якщо точка
* розташована на краю функціонального блоку.
*
* @param position Нова позиція координати.
* @param type Тип координати, переміщення якої має відбуватись.
* @return true, якщо перміщення можливе, false, якщо переміщення не
* можливе.
*/
private boolean isMoveableFunctionPoint(final double position, final int type) {
int funType;
Function fun;
if (isStart()) {
funType = sector.getSector().getStart().getFunctionType();
fun = sector.getSector().getStart().getFunction();
} else {
funType = sector.getSector().getEnd().getFunctionType();
fun = sector.getSector().getEnd().getFunction();
}
if (isMoveableDFDSRow(fun))
return true;
IDEF0Object function = sector.getMovingArea().getIDEF0Object(fun);
if (funType == MovingPanel.LEFT || funType == MovingPanel.RIGHT) {
if (type == Ordinate.TYPE_Y)
return position >= function.getBounds().getTop() && position <= function.getBounds().getBottom();
else {
if (funType == MovingPanel.LEFT)
return position > sector.getPoint(sector.getPointCount() - 2).getX();
else
return position < sector.getPoint(1).getX();
}
} else {
if (type == Ordinate.TYPE_X)
return position >= function.getBounds().getLeft() && position <= function.getBounds().getRight();
else {
if (funType == MovingPanel.TOP)
return position > sector.getPoint(sector.getPointCount() - 2).getY();
else
return position < sector.getPoint(sector.getPointCount() - 2).getY();
}
}
}
use of com.ramussoft.pb.Function in project ramus by Vitaliy-Yakovchuk.
the class ArrowPainter method paintTop.
public void paintTop(final Graphics2D g, final int height, MovingArea area, Font font2, int partNumber, int hPageCount) {
if (!area.isPrinting()) {
if (!MovingArea.DISABLE_RENDERING_HINTS) {
g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
}
}
int width = movingArea.getIntOrdinate(movingArea.MOVING_AREA_WIDTH);
width /= hPageCount;
int left = 0;
if (partNumber > 0) {
left = width * partNumber;
width += 1;
}
g.drawLine(left, 0, left, height);
g.drawLine(left + width - 1, 0, left + width - 1, height);
g.drawRect(left, 0, width - 1, height - 1);
final int div = (int) ((width / height) * 0.65d);
final int x = left + width - width / div;
g.drawLine(x, 0, x, height - 1);
g.setFont(movingArea.getFont(font2));
final int height2 = height - 8 - (int) g.getFont().getStringBounds(CONTEXT_T, g.getFontRenderContext()).getHeight();
g.drawString(CONTEXT_T, x + 5, 5 + (int) g.getFont().getStringBounds(CONTEXT_T, g.getFontRenderContext()).getHeight());
final Function activeFunction = movingArea.getActiveFunction();
if (activeFunction == movingArea.dataPlugin.getBaseFunction()) {
g.setFont(movingArea.getFont(font2));
final int textWidth = (int) g.getFont().getStringBounds(TOP_T, g.getFontRenderContext()).getWidth();
final int textHeight = (int) g.getFont().getStringBounds(TOP_T, g.getFontRenderContext()).getHeight();
g.drawString(TOP_T, x + (width / div - textWidth) / 2, (height - textHeight) / 2 + textHeight);
} else {
final Vector v = movingArea.dataPlugin.getChilds(activeFunction.getParentRow(), true);
final int width2 = width - x + left;
for (int i = 0; i < v.size(); i++) {
final Function f = (Function) v.get(i);
final int x1 = (int) (f.getBounds().getX() * width2 / movingArea.getDoubleWidth());
final int y1 = (int) (f.getBounds().getY() * height2 / movingArea.getDoubleHeight());
final int width1 = (int) (f.getBounds().getWidth() * width2 / movingArea.getDoubleWidth());
final int height1 = (int) (f.getBounds().getHeight() * height2 / movingArea.getDoubleHeight());
if (f.equals(activeFunction))
g.fillRect(x + x1, y1 + height - height2, width1, height1);
else
g.drawRect(x + x1, y1 + height - height2, width1, height1);
}
}
g.setFont(movingArea.getFont(font2));
final int h2 = height - 1;
final int x2 = left + (int) (width / 2.0);
g.drawLine(x2, 0, x2, h2);
final int w = height / 4;
final int w2 = (x - x2 + w) / 2;
g.drawLine(x2 + w, 0, x2 + w, h2);
g.drawLine(x2 + w2, 0, x2 + w2, h2);
String s;
int h;
final ProjectOptions projectOptions = activeFunction.getProjectOptions();
final Readed[] rs = projectOptions.getReadedModel().getSortReaded(3);
for (int i = 0; i < 4; i++) {
if (i == 0) {
s = READER_B;
h = (int) g.getFont().getStringBounds(s, g.getFontRenderContext()).getHeight();
g.drawString(s, x2 + w2 + 2, (i + 1) * w - (w - h) / 2);
s = DATE_B;
h = (int) g.getFont().getStringBounds(s, g.getFontRenderContext()).getHeight();
final int ww = (int) g.getFont().getStringBounds(s, g.getFontRenderContext()).getWidth();
g.drawString(s, x - 2 - ww, (i + 1) * w - (w - h) / 2);
} else if (i <= rs.length) {
s = rs[i - 1].getReader();
if (s.length() > 13) {
s = s.substring(0, 10) + "...";
}
h = (int) g.getFont().getStringBounds(s, g.getFontRenderContext()).getHeight();
g.drawString(s, x2 + w2 + 2, (i + 1) * w - (w - h) / 2);
s = rs[i - 1].getDate();
h = (int) g.getFont().getStringBounds(s, g.getFontRenderContext()).getHeight();
final int ww = (int) g.getFont().getStringBounds(s, g.getFontRenderContext()).getWidth();
g.drawString(s, x - 2 - ww, (i + 1) * w - (w - h) / 2);
}
g.drawLine(x2, i * w, x, i * w);
s = ResourceLoader.getString(Status.STATUS_NAMES[i]);
h = (int) g.getFont().getStringBounds(s, g.getFontRenderContext()).getHeight();
g.drawString(s, x2 + w + 2, (i + 1) * w - (w - h) / 2);
if (activeFunction.getStatus().getType() == i)
g.fillRect(x2, i * w, w, w);
}
final int x3 = left + width / 6;
g.drawLine(x3, 0, x3, h2);
s = AUTOR_T + activeFunction.getAuthor();
h = (int) g.getFont().getStringBounds(s, g.getFontRenderContext()).getHeight();
g.drawString(s, x3 + 2, w - (w - h) / 2);
s = PROJECT_T + " ";
final int projectTitileWidth = (int) g.getFont().getStringBounds(s, g.getFontRenderContext()).getWidth();
h = (int) g.getFont().getStringBounds(s, g.getFontRenderContext()).getHeight();
g.drawString(s, x3 + 2, 2 * w - (w - h) / 2);
s = TOP_IDEF_NOTES;
final int t1 = 4 * w - (w - h) / 2;
g.drawString(s, x3 + 2, t1);
int wi1 = (int) g.getFont().getStringBounds(s, g.getFontRenderContext()).getWidth() + 8 + x3;
for (int i = 1; i <= 10; i++) {
s = Integer.toString(i);
g.drawString(s, wi1, t1);
wi1 += (int) g.getFont().getStringBounds(s, g.getFontRenderContext()).getWidth() + 5;
}
final String d1 = DATE_T + " ";
final String d2 = REV_T + " ";
wi1 = (int) g.getFont().getStringBounds(d1, g.getFontRenderContext()).getWidth();
final int wi2 = (int) g.getFont().getStringBounds(d2, g.getFontRenderContext()).getWidth();
final int wi = wi1 > wi2 ? wi1 : wi2;
String createDate = Readed.dateFormat.format(activeFunction.getCreateDate());
final int dw = (int) g.getFont().getStringBounds(createDate, g.getFontRenderContext()).getWidth();
final String pn = projectOptions.getProjectName();
g.setFont(font2);
movingArea.paintText(g, pn, movingArea.getFBounds(new Rectangle(x3 + 2 + projectTitileWidth, (int) (1.45 * w - (w - h) / 2), x2 - 4 - wi - dw - (x3 + 2 + projectTitileWidth), height - w)), Line.CENTER_ALIGN, 0, true);
g.setFont(movingArea.getFont(font2));
g.drawString(d1, x2 - 2 - wi - dw, w - (w - h) / 2);
g.drawString(d2, x2 - 2 - wi - dw, 2 * w - (w - h) / 2);
g.drawString(createDate, x2 - 2 - dw, w - (w - h) / 2);
String revDate = Readed.dateFormat.format(activeFunction.getRevDate());
g.drawString(revDate, x2 - 2 - dw, 2 * w - (w - h) / 2);
s = USED_AT_T;
h = (int) g.getFont().getStringBounds(s, g.getFontRenderContext()).getHeight();
g.drawString(s, left + 5, 5 + h);
s = projectOptions.getUsedAt();
g.setFont(font2);
movingArea.paintText(g, s, movingArea.getFBounds(new Rectangle(left + 5, h + 3, x3 - 11 - left, height - h - 8)), Line.CENTER_ALIGN, 1, true);
}
use of com.ramussoft.pb.Function in project ramus by Vitaliy-Yakovchuk.
the class IDEF0TabView method createPanel.
private void createPanel() {
panel = new IDEFPanel(frame, dataPlugin, framework, rules, this) {
@Override
protected void openTab(Function function) {
long id = -1;
if (!dataPlugin.getBaseFunction().equals(function))
id = function.getElement().getId();
OpenDiagram openDiagram = new OpenDiagram(dataPlugin.getBaseFunctionQualifier(), id);
framework.propertyChanged(IDEF0ViewPlugin.OPEN_DIAGRAM, openDiagram);
}
@Override
protected void setActiveObject(Object activeObject) {
super.setActiveObject(activeObject);
if (activeObject instanceof VisualPanel)
activaPanel = (VisualPanel) activeObject;
if ((Boolean) handAction.getValue(AbstractAction.SELECTED_KEY)) {
if (activeObject instanceof VisualPanel) {
panel.getMovingArea().startUserTransaction();
VisualPanel vpanel = (VisualPanel) activeObject;
visualCopy.copyTo(vpanel);
panel.getMovingArea().commitUserTransaction();
}
} else {
if (activeObject instanceof VisualPanel) {
handAction.setEnabled(true);
} else
handAction.setEnabled(false);
}
}
};
Function function = null;
if (functionId >= 0) {
function = (Function) dataPlugin.findRowByGlobalId(functionId);
}
if (function == null)
function = dataPlugin.getBaseFunction();
panel.getMovingArea().setActiveFunction(function);
panel.getMovingArea().addActiveFunctionListener(new ActiveFunctionListener() {
@Override
public void activeFunctionChanged(ActiveFunctionEvent event) {
refreshTitle();
framework.propertyChanged(ACTIVE_DIAGRAM, getOpenAction());
}
});
frame.getActiveZoom().doZoom(panel);
basePanel.add(panel, BorderLayout.CENTER);
}
use of com.ramussoft.pb.Function in project ramus by Vitaliy-Yakovchuk.
the class IDEF0TabView method getFunctionId.
private long getFunctionId() {
Function function = panel.getMovingArea().getActiveFunction();
long id = -1;
if (!function.equals(dataPlugin.getBaseFunction()))
id = function.getElement().getId();
return id;
}
Aggregations