use of com.ramussoft.pb.idef.elements.PaintSector.Pin in project ramus by Vitaliy-Yakovchuk.
the class Point method isCanConnected.
private int isCanConnected(final double x, final double y, final int pinType, boolean startPoint) {
final PaintSector.Pin[] pins = getPins(pinType);
int res = isCanConnected(x, y, pinType);
if (res != -1) {
if (!startPoint)
tmpType = MovingPanel.getOpposite(tmpType);
if (pins.length > 0) {
final PaintSector.Pin pin = pins[0];
if (tmpType != pin.getWayType())
res = -1;
}
}
return res;
}
use of com.ramussoft.pb.idef.elements.PaintSector.Pin in project ramus by Vitaliy-Yakovchuk.
the class Point method isCanConnected.
private int isCanConnected(final double x, final double y, final int pinType) {
// Набір паралельних
final PaintSector.Pin[] pins = getPins(pinType);
// частин.
int type;
if (pinType == PaintSector.PIN_TYPE_Y) {
if (y < getY())
type = MovingPanel.TOP;
else
type = MovingPanel.BOTTOM;
for (final Pin element : pins) if (element.getEnterWay(this) == type)
return -1;
} else {
if (x < getX())
type = MovingPanel.LEFT;
else
type = MovingPanel.RIGHT;
for (final Pin element : pins) if (element.getEnterWay(this) == type)
return -1;
}
tmpType = type;
return pinType;
}
use of com.ramussoft.pb.idef.elements.PaintSector.Pin in project ramus by Vitaliy-Yakovchuk.
the class SectorColorAttributePlugin method getTableCellEditor.
@Override
public TableCellEditor getTableCellEditor(final Engine engine, final AccessRules rules, final Attribute attribute) {
final JComboBox box = new JComboBox();
box.setRenderer(comboBoxRenderer);
box.addItem(Color.white);
box.addItem(Color.green);
box.addItem(Color.blue);
box.addItem(Color.red);
box.addItem(Color.yellow);
box.addItem(Color.cyan);
box.addItem(Color.magenta);
box.addItem(Color.orange);
box.addItem(Color.pink);
box.addItem(Color.lightGray);
box.addItem(Color.gray);
box.addItem(Color.darkGray);
box.addItem(Color.black);
return new DefaultCellEditor(box) {
private Pin pin;
@Override
public boolean stopCellEditing() {
if (box.getSelectedItem() instanceof Color) {
((Journaled) engine).startUserTransaction();
apply((Color) box.getSelectedItem(), pin);
return super.stopCellEditing();
}
return false;
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
pin = (Pin) ((MetadataGetter) table).getMetadata();
return super.getTableCellEditorComponent(table, value, isSelected, row, column);
}
};
}
use of com.ramussoft.pb.idef.elements.PaintSector.Pin in project ramus by Vitaliy-Yakovchuk.
the class LineStyleAttributePlugin method getAttributeEditor.
@Override
public AttributeEditor getAttributeEditor(final Engine engine, final AccessRules rules, final Element element, final Attribute attribute, AttributeEditor old) {
if (old != null)
old.close();
return new AbstractAttributeEditor() {
private PaintSector.Pin pin;
private LineStyleChooser component;
private Stroke stroke;
{
component = new LineStyleChooser();
}
@Override
public Object setValue(Object value) {
this.pin = (PaintSector.Pin) value;
stroke = pin.getSector().getStroke();
component.setStroke(stroke);
return value;
}
@Override
public Object getValue() {
return pin;
}
@Override
public void apply(Engine engine, Element element, Attribute attribute, Object value) {
LineStyleAttributePlugin.this.apply(component.getStroke(), pin);
}
@Override
public JComponent getComponent() {
return component;
}
@Override
public boolean isSaveAnyway() {
return !stroke.equals(component.getStroke());
}
};
}
use of com.ramussoft.pb.idef.elements.PaintSector.Pin in project ramus by Vitaliy-Yakovchuk.
the class MovingArea method paint.
@Override
public void paint(final Graphics gr) {
synchronized (paintLock) {
painted = true;
}
if (oldH != getHeight() || oldW != getWidth())
synchronized (backgroundPaintlock) {
if (bImage != null) {
oldH = getHeight();
oldW = getWidth();
bImage = null;
}
}
Graphics2D g = (Graphics2D) gr;
boolean initRepaint = false;
synchronized (backgroundPaintlock) {
if (bImage == null) {
paintBackground(gr);
if (!printing)
initRepaint = true;
} else
g.drawImage(bImage, 0, 0, null);
}
if (initRepaint && getComponentCount() == 0)
init();
if (!DISABLE_RENDERING_HINTS && !isPrinting()) {
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);
}
if (enteredPanel != null && enteredPanel != pressedPanel)
enteredPanel.paintBorder(g);
Composite comp = g.getComposite();
g.setComposite(a);
if (mousePressed) {
if (pressedPanel != null)
pressedPanel.paint(g);
if (activeObject instanceof Pin)
try {
((Pin) activeObject).getSector().paint(g, this);
} catch (Exception e) {
e.printStackTrace();
}
if (mouseSelection != null) {
for (MovingPanel panel : panels) {
if (mouseSelection.contains(panel))
panel.paint(g);
}
}
}
g.setComposite(comp);
if (enteredPanel instanceof IDEF0Object) {
g.setColor(Color.BLACK);
((IDEF0Object) enteredPanel).paintTringle(g);
}
if (mousePin != null) {
mousePin.getSector().paint(g, this);
}
if (!printing) {
final int borderWidth = getIntOrdinate(BORDER_WIDTH);
switch(getBorderType()) {
case MovingPanel.LEFT:
{
g.fillRect(getIntOrdinate(LEFT_PART), getIntOrdinate(TOP_PART), borderWidth, getIntOrdinate(CLIENT_HEIGHT));
}
break;
case MovingPanel.TOP:
{
g.fillRect(getIntOrdinate(LEFT_PART), getIntOrdinate(TOP_PART), getIntOrdinate(CLIENT_WIDTH), borderWidth);
}
break;
case MovingPanel.RIGHT:
{
g.fillRect(getIntOrdinate(CLIENT_WIDTH + LEFT_PART) - borderWidth, getIntOrdinate(TOP_PART), borderWidth, getHeight());
}
break;
case MovingPanel.BOTTOM:
{
g.fillRect(getIntOrdinate(LEFT_PART), getIntOrdinate(TOP_PART + CLIENT_HEIGHT) - borderWidth, getIntOrdinate(CLIENT_WIDTH), borderWidth);
}
break;
}
if (getChangingState() == ARROW_CHANGING_STATE && mp != null && getState() != START_POINT_ADDING) {
if (getCurrentMovingArea() != this) {
if (pressPanelMoveType >= 0) {
int x1 = mp.x;
int y1 = mp.y;
switch(pressPanelMoveType) {
case MovingFunction.LEFT:
x1 = getIntOrdinate(0);
break;
case MovingFunction.RIGHT:
x1 = getIntOrdinate(CLIENT_WIDTH);
break;
case MovingFunction.TOP:
y1 = getIntOrdinate(0);
break;
case MovingFunction.BOTTOM:
y1 = getIntOrdinate(CLIENT_HEIGHT);
break;
}
final float[] d = { 5, 10 };
g.setColor(Color.black);
g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 10, d, 0));
g.drawLine(x1, y1, mp.x, mp.y);
}
} else {
if (crosstunnel) {
final int x1 = getIntOrdinate(refactor.getX());
final int y1 = getIntOrdinate(refactor.getY());
final float[] d = { 5, 10 };
g.setColor(Color.black);
g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 10, d, 0));
if (getPointChangingType() == SectorRefactor.TYPE_END)
g.drawLine(x1, y1, getIntOrdinate(CLIENT_WIDTH), y1);
else
g.drawLine(x1, y1, getIntOrdinate(0), y1);
} else {
final int x1 = getIntOrdinate(refactor.getX());
final int y1 = getIntOrdinate(refactor.getY());
final float[] d = { 5, 10 };
g.setColor(Color.black);
g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 10, d, 0));
g.drawLine(x1, y1, mp.x, mp.y);
}
}
} else if ((getChangingState() == ARROW_STATE) && (pressPanelMoveType >= 0)) {
MovingArea ma = (MovingArea) panel.getFramework().get(CURRENT_MOVING_AREA);
if ((ma != null) && (ma.getState() == ARROW_CHANGING_STATE) && (ma.getPointChangingType() == SectorRefactor.TYPE_END)) {
}
}
}
if (mouseSelection != null) {
g.setStroke(new BasicStroke(1.5f, 1, 1, 1, new float[] { 1f, 5f }, 0f));
g.setColor(Color.DARK_GRAY);
if (mouseSelection.dr) {
if (mouseSelection.width >= 0 && mouseSelection.height >= 0)
g.draw(mouseSelection);
else {
double x = mouseSelection.x;
double y = mouseSelection.y;
if (mouseSelection.width < 0)
x += mouseSelection.width;
if (mouseSelection.height < 0)
y += mouseSelection.height;
g.draw(new Rectangle2D.Double(x, y, Math.abs(mouseSelection.width), Math.abs(mouseSelection.height)));
}
}
mouseSelection.paint(g, this);
}
}
Aggregations