use of com.ramussoft.pb.idef.visual.ArrowedStroke in project ramus by Vitaliy-Yakovchuk.
the class DataLoader method readStroke.
public static Stroke readStroke(final InputStream stream, final MemoryData data) throws IOException {
if (readBoolean(stream)) {
final float lineWidth = (float) readDouble(stream);
final int ec = readInteger(stream);
final int lj = readInteger(stream);
final float dp = (float) readDouble(stream);
final float ml = (float) readDouble(stream);
final int len = readInteger(stream);
float[] ar = null;
if (len > 0) {
ar = new float[len];
for (int i = 0; i < ar.length; i++) ar[i] = (float) readDouble(stream);
}
final BasicStroke bs = new BasicStroke(lineWidth, ec, lj, ml, ar, dp);
data.stroukes.add(bs);
return bs;
} else {
int type = readInteger(stream);
if (type == -10) {
WayStroke wayStroke = new WayStroke(-1);
wayStroke.setType(0);
return wayStroke;
}
if (type == -11) {
WayStroke wayStroke = new WayStroke(-1);
wayStroke.setType(1);
return wayStroke;
}
if (type == -12) {
WayStroke wayStroke = new WayStroke(-1);
wayStroke.setType(2);
return wayStroke;
}
if (type == -20) {
ArrowedStroke arrowedStroke = new ArrowedStroke(-1, -1);
arrowedStroke.setType(0);
return arrowedStroke;
}
if (type == -21) {
ArrowedStroke arrowedStroke = new ArrowedStroke(-1, -1);
arrowedStroke.setType(1);
return arrowedStroke;
}
if (type == -22) {
ArrowedStroke arrowedStroke = new ArrowedStroke(-1, -1);
arrowedStroke.setType(2);
return arrowedStroke;
}
if (data.stroukes.size() <= type)
return new BasicStroke();
return (BasicStroke) data.stroukes.get(type);
}
}
use of com.ramussoft.pb.idef.visual.ArrowedStroke in project ramus by Vitaliy-Yakovchuk.
the class DataSaver method saveStroke.
public static void saveStroke(final OutputStream stream, final Stroke stroke, final MemoryData memoryData) throws IOException {
if (stroke instanceof BasicStroke) {
BasicStroke basickStroke = (BasicStroke) stroke;
saveBoolean(stream, true);
saveDouble(stream, basickStroke.getLineWidth());
saveInteger(stream, basickStroke.getEndCap());
saveInteger(stream, basickStroke.getLineJoin());
saveDouble(stream, basickStroke.getDashPhase());
saveDouble(stream, basickStroke.getMiterLimit());
final float[] ar = basickStroke.getDashArray();
if (ar == null)
saveInteger(stream, -1);
else {
saveInteger(stream, ar.length);
for (final float element : ar) saveDouble(stream, element);
}
memoryData.stroukes.add(stroke);
} else if (stroke instanceof WayStroke) {
saveBoolean(stream, false);
saveInteger(stream, -10 - ((WayStroke) stroke).getType());
} else if (stroke instanceof ArrowedStroke) {
saveBoolean(stream, false);
saveInteger(stream, -20 - ((ArrowedStroke) stroke).getType());
}
}
use of com.ramussoft.pb.idef.visual.ArrowedStroke in project ramus by Vitaliy-Yakovchuk.
the class PaintSector method paint.
/**
* Малює сектор, використовуючи параметри movingArea.
*
* @param g Об’єкт для малювання.
* @param movingArea Об’єкт для завантаження параметрів.
*/
public void paint(final Graphics2D g, final MovingArea movingArea) {
g.setColor(getColor());
g.setFont(getFont());
arrowPainter = new ArrowPainter(movingArea);
if (movingArea.getMousePin() != null && movingArea.getMousePin().getSector() == this && !selStart && !selEnd || isSelected(movingArea))
g.setStroke(getBoldStroke());
else {
Stroke stroke = getStroke();
if (stroke instanceof WayStroke) {
final float arrowWidth = (float) movingArea.getIDoubleOrdinate(ArrowPainter.ARROW_WIDTH);
WayStroke wayStroke = (WayStroke) stroke;
if (wayStroke.getType() == 0)
wayStroke.setArrowWidth(arrowWidth);
else if (wayStroke.getType() == 1)
wayStroke.setArrowWidth(arrowWidth / 2);
else
wayStroke.setArrowWidth(arrowWidth / 3);
} else if (stroke instanceof ArrowedStroke) {
final float arrowWidth = (float) movingArea.getIDoubleOrdinate(ArrowPainter.ARROW_WIDTH);
final float arrowHeight = (float) movingArea.getIDoubleOrdinate(ArrowPainter.ARROW_HEIGHT);
g.setStroke(new ArrowedStroke(arrowWidth, arrowHeight));
ArrowedStroke arrowedStroke = (ArrowedStroke) stroke;
if (arrowedStroke.getType() == 0) {
arrowedStroke.setArrowWidth(arrowWidth);
arrowedStroke.setArrowHeight(arrowHeight);
} else if (arrowedStroke.getType() == 1) {
arrowedStroke.setArrowWidth(arrowWidth / 2);
arrowedStroke.setArrowHeight(arrowHeight / 2);
} else {
arrowedStroke.setArrowWidth(arrowWidth / 3);
arrowedStroke.setArrowHeight(arrowHeight / 3);
}
}
g.setStroke(stroke);
}
for (int i = 0; i < getPinCount(); i++) getPin(i).paint(g, movingArea);
if (showTilda && text != null)
arrowPainter.paintTilda(g, this);
switch(getStartTunnelType()) {
case Crosspoint.TUNNEL_SIMPLE_SOFT:
case Crosspoint.TUNNEL_SOFT:
{
arrowPainter.paintTunnel(g, getStartPoint().getPoint(), getVectorType(SectorRefactor.TYPE_START), true);
}
break;
case Crosspoint.TUNNEL_HARD:
{
arrowPainter.paintTunnel(g, getStartPoint().getPoint(), getVectorType(SectorRefactor.TYPE_START), false);
}
break;
case Crosspoint.TUNNEL_NONE:
{
int borderType = getSector().getStart().getBorderType();
NCrosspoint crosspoint = (NCrosspoint) getStart();
if ((borderType >= 0) && (crosspoint != null) && (crosspoint.isOneInOut())) {
NSector in = (NSector) crosspoint.getIn();
Function outer = in.getFunction();
NSector out = (NSector) crosspoint.getOut();
Function inner = out.getFunction();
if ((inner != null) && (inner.getParent() != null) && (!inner.getParent().equals(outer))) {
arrowPainter.paintLink(g, getStartPoint().getPoint(), getVectorType(SectorRefactor.TYPE_START), inner, outer);
}
}
}
break;
}
switch(getEndTunnelType()) {
case Crosspoint.TUNNEL_SIMPLE_SOFT:
case Crosspoint.TUNNEL_SOFT:
{
arrowPainter.paintTunnel(g, getEndPoint().getPoint(), getVectorType(SectorRefactor.TYPE_END), true);
}
break;
case Crosspoint.TUNNEL_HARD:
{
arrowPainter.paintTunnel(g, getEndPoint().getPoint(), getVectorType(SectorRefactor.TYPE_END), false);
}
break;
case Crosspoint.TUNNEL_NONE:
{
int borderType = getSector().getEnd().getBorderType();
NCrosspoint crosspoint = (NCrosspoint) getEnd();
if ((borderType >= 0) && (crosspoint != null) && (crosspoint.isOneInOut())) {
Function outer = crosspoint.getOut().getFunction();
Function inner = crosspoint.getIn().getFunction();
if ((inner != null) && (inner.getParent() != null) && (!inner.getParent().equals(outer))) {
arrowPainter.paintLink(g, getEndPoint().getPoint(), getVectorType(SectorRefactor.TYPE_END), inner, outer);
}
}
}
break;
}
}
Aggregations