use of net.sf.latexdraw.models.interfaces.shape.IGrid in project latexdraw by arnobl.
the class PSTLatexdrawListener method exitPsgrid.
@Override
public void exitPsgrid(final net.sf.latexdraw.parsers.pst.PSTParser.PsgridContext ctx) {
final IGrid grid = ShapeFactory.INST.createGrid(ShapeFactory.INST.createPoint());
final IPoint gridStart;
final IPoint gridEnd;
final IPoint pos;
boolean isGridXLabelInverted = false;
boolean isGridYLabelInverted = false;
if (ctx.p3 == null) {
if (ctx.p2 == null) {
if (ctx.p1 == null) {
gridStart = ShapeFactory.INST.createPoint(Math.round(ctx.pstctx.pictureSWPt.getX()), Math.round(ctx.pstctx.pictureSWPt.getY()));
gridEnd = ShapeFactory.INST.createPoint(Math.round(ctx.pstctx.pictureNEPt.getX()), Math.round(ctx.pstctx.pictureNEPt.getY()));
pos = ShapeFactory.INST.createPoint();
grid.setPosition(0d, 0d);
grid.setLabelsSize(0);
} else {
pos = ShapeFactory.INST.createPoint();
gridStart = ShapeFactory.INST.createPoint();
gridEnd = ShapeFactory.INST.createPoint(ctx.pstctx.coordToRawPoint(ctx.p1));
}
} else {
pos = ShapeFactory.INST.createPoint(ctx.pstctx.coordToRawPoint(ctx.p1));
gridStart = ShapeFactory.INST.createPoint(ctx.pstctx.coordToRawPoint(ctx.p1));
gridEnd = ShapeFactory.INST.createPoint(ctx.pstctx.coordToRawPoint(ctx.p2));
}
} else {
pos = ShapeFactory.INST.createPoint(ctx.pstctx.coordToRawPoint(ctx.p1));
gridStart = ShapeFactory.INST.createPoint(ctx.pstctx.coordToRawPoint(ctx.p2));
gridEnd = ShapeFactory.INST.createPoint(ctx.pstctx.coordToRawPoint(ctx.p3));
}
if (gridStart.getX() >= gridEnd.getX()) {
final double tmp = gridEnd.getX();
gridEnd.setX(gridStart.getX());
gridStart.setX(tmp);
isGridXLabelInverted = true;
}
if (gridStart.getY() >= gridEnd.getY()) {
final double tmp = gridEnd.getY();
gridEnd.setY(gridStart.getY());
gridStart.setY(tmp);
isGridYLabelInverted = true;
}
setStdGridParams(pos.getX(), pos.getY(), grid, ctx.pstctx);
setShapeParameters(grid, ctx.pstctx);
grid.setPosition(0d, 0d);
grid.setUnit(ctx.pstctx.unit);
grid.setGridDots((int) ctx.pstctx.gridDots);
grid.setGridLabelsColour(ctx.pstctx.gridlabelcolor);
grid.setLabelsSize((int) (ctx.pstctx.gridLabel * IShape.PPC));
grid.setGridWidth(Math.abs(ctx.pstctx.gridWidth * IShape.PPC));
grid.setSubGridColour(ctx.pstctx.subGridCol);
grid.setSubGridDiv((int) ctx.pstctx.subGridDiv);
grid.setSubGridDots((int) ctx.pstctx.subGridDots);
grid.setSubGridWidth(Math.abs(ctx.pstctx.subGridWidth * IShape.PPC));
grid.setLineColour(ctx.pstctx.gridColor);
grid.setXLabelSouth(!isGridYLabelInverted);
grid.setYLabelWest(!isGridXLabelInverted);
grid.setGridEndX(gridEnd.getX());
grid.setGridEndY(gridEnd.getY());
grid.setGridStartX(gridStart.getX());
grid.setGridStartY(gridStart.getY());
shapes.peek().addShape(grid);
}
use of net.sf.latexdraw.models.interfaces.shape.IGrid in project latexdraw by arnobl.
the class LGrid method duplicate.
@Override
public IGrid duplicate() {
final IGrid grid = ShapeFactory.INST.createGrid(getPosition());
grid.copy(this);
return grid;
}
use of net.sf.latexdraw.models.interfaces.shape.IGrid in project latexdraw by arnobl.
the class TestHandGridStyle method testPickLineColourHand.
@Test
public void testPickLineColourHand() {
new CompositeGUIVoidCommand(activateHand, selectionAddDot, selectionAddGrid, selectionAddGrid, updateIns).execute();
Color col = colourSubGrid.getValue();
pickcolourSubGrid.execute();
assertEquals(colourSubGrid.getValue(), ((IGrid) drawing.getSelection().getShapeAt(1)).getSubGridColour().toJFX());
assertEquals(colourSubGrid.getValue(), ((IGrid) drawing.getSelection().getShapeAt(2)).getSubGridColour().toJFX());
assertNotEquals(col, colourSubGrid.getValue());
}
use of net.sf.latexdraw.models.interfaces.shape.IGrid in project latexdraw by arnobl.
the class TestModifyShapeProperty method configureShapes.
private void configureShapes() {
final IGrid grid = ShapeFactory.INST.createGrid(ShapeFactory.INST.createPoint());
final IAxes axes = ShapeFactory.INST.createAxes(ShapeFactory.INST.createPoint());
final IDot dot = ShapeFactory.INST.createDot(ShapeFactory.INST.createPoint());
final ICircle circle = ShapeFactory.INST.createCircle();
final IEllipse ell = ShapeFactory.INST.createEllipse();
final IText txt = ShapeFactory.INST.createText();
final IBezierCurve bc = ShapeFactory.INST.createBezierCurve(Collections.emptyList());
final IPolyline pl = ShapeFactory.INST.createPolyline(Collections.emptyList());
final IPolygon pg = ShapeFactory.INST.createPolygon(Collections.emptyList());
final ITriangle tr = ShapeFactory.INST.createTriangle();
final IRhombus rh = ShapeFactory.INST.createRhombus();
final IRectangle r1 = ShapeFactory.INST.createRectangle();
final IPlot plot = ShapeFactory.INST.createPlot(ShapeFactory.INST.createPoint(), 0d, 1d, "x", false);
final ICircleArc carc = ShapeFactory.INST.createCircleArc();
final ISquare sq = ShapeFactory.INST.createSquare();
final IFreehand fh = ShapeFactory.INST.createFreeHand(Collections.emptyList());
r1.setLineStyle(LineStyle.DASHED);
r1.setBordersPosition(BorderPos.INTO);
r1.setFillingStyle(FillingStyle.PLAIN);
r1.setThickness(2.3);
r1.setHasDbleBord(true);
r1.setLineArc(0.2);
r1.setDbleBordSep(1.3);
r1.setHatchingsAngle(0.33);
r1.setHatchingsSep(9.1);
r1.setHatchingsWidth(12.11);
r1.setShadowAngle(0.1);
r1.setGradMidPt(0.66);
r1.setHatchingsCol(DviPsColors.CYAN);
r1.setLineColour(DviPsColors.NAVYBLUE);
r1.setShadowSize(87.2);
r1.setFillingCol(DviPsColors.CARNATIONPINK);
r1.setShadowCol(DviPsColors.CORNFLOWERBLUE);
r1.setDashSepBlack(1.2);
r1.setDashSepWhite(2.1);
r1.setDotSep(23.1);
r1.setGradAngle(1.3);
r1.setDbleBordCol(DviPsColors.RED);
r1.setGradColEnd(DviPsColors.BITTERSWEET);
r1.setGradColStart(DviPsColors.FORESTGREEN);
r1.setShowPts(true);
final IRectangle r2 = ShapeFactory.INST.createRectangle();
r2.setLineStyle(LineStyle.SOLID);
r2.setBordersPosition(BorderPos.MID);
r2.setFillingStyle(FillingStyle.HLINES);
r2.setThickness(6.3);
r2.setHasShadow(true);
r2.setLineArc(0.33);
r2.setDbleBordSep(2.3);
r2.setHatchingsAngle(-0.53);
r2.setHatchingsSep(1.1);
r2.setHatchingsWidth(2.11);
r2.setShadowAngle(-0.1);
r2.setGradMidPt(0.31);
r2.setHatchingsCol(DviPsColors.APRICOT);
r2.setLineColour(DviPsColors.YELLOW);
r2.setShadowSize(8.1);
r2.setFillingCol(DviPsColors.CERULEAN);
r2.setShadowCol(DviPsColors.DARKORCHID);
r1.setDashSepBlack(11.2);
r1.setDashSepWhite(21.1);
r1.setDotSep(231.1);
r1.setGradAngle(11.3);
r1.setDbleBordCol(DviPsColors.ROYALBLUE);
r1.setGradColEnd(DviPsColors.CADETBLUE);
r1.setGradColStart(DviPsColors.OLIVE);
txt.copy(r1);
ell.copy(r1);
circle.copy(r2);
dot.copy(r2);
bc.copy(r2);
pl.copy(r1);
pg.copy(r2);
tr.copy(r1);
rh.copy(r2);
plot.copy(r1);
carc.copy(r2);
sq.copy(r1);
fh.copy(r2);
group.addShape(r1);
group.addShape(txt);
group.addShape(grid);
group.addShape(pl);
group.addShape(pg);
group.addShape(r2);
group.addShape(axes);
group.addShape(ell);
group.addShape(circle);
group.addShape(tr);
group.addShape(rh);
group.addShape(dot);
group.addShape(bc);
group.addShape(plot);
group.addShape(carc);
group.addShape(sq);
group.addShape(fh);
}
use of net.sf.latexdraw.models.interfaces.shape.IGrid in project latexdraw by arnobl.
the class TestPencilGridStyle method testPickLineColourPencil.
@Test
public void testPickLineColourPencil() {
new CompositeGUIVoidCommand(activatePencil, pencilCreatesGrid, updateIns).execute();
Color col = colourSubGrid.getValue();
pickcolourSubGrid.execute();
assertEquals(colourSubGrid.getValue(), ((IGrid) pencil.createShapeInstance()).getSubGridColour().toJFX());
assertNotEquals(col, colourSubGrid.getValue());
}
Aggregations