Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* This file is part of VisiCut.
* Copyright (C) 2011 Thomas Oster <thomas.oster@rwth-aachen.de>
* RWTH Aachen University - 52062 Aachen, Germany
*
* VisiCut is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VisiCut is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with VisiCut. If not, see <http://www.gnu.org/licenses/>.
**/
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.t_oster.liblasercut;
import java.util.LinkedList;
import java.util.List;
/**
*
* @author Thomas Oster <thomas.oster@rwth-aachen.de>
*/
public class VectorPart
{
private LaserProperty currentCuttingProperty;
private int maxX;
private int maxY;
private int minX;
private int minY;
private List<VectorCommand> commands;
public VectorPart(LaserProperty initialProperty)
{
commands = new LinkedList<VectorCommand>();
}
public LaserProperty getCurrentCuttingProperty()
{
return currentCuttingProperty;
}
this.currentCuttingProperty = cp;
commands.add(new VectorCommand(VectorCommand.CmdType.SETPROPERTY, cp));
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
}
public VectorCommand[] getCommandList()
{
return commands.toArray(new VectorCommand[0]);
}
private void checkMin(int x, int y)
{
if (x < minX)
{
minX = x;
}
if (y < minY)
{
minY = y;
}
}
private void checkMax(int x, int y)
{
if (x > maxX)
{
maxX = x;
}
if (y > maxY)
{
maxY = y;
}
}
public void moveto(int x, int y)
{
commands.add(new VectorCommand(VectorCommand.CmdType.MOVETO, x, y));
checkMin(x, y);
checkMax(x, y);
}
public void lineto(int x, int y)
{
commands.add(new VectorCommand(VectorCommand.CmdType.LINETO, x, y));
checkMin(x, y);
checkMax(x, y);
}
/**
* Returns the Width of the CuttingPart in Pixels
* @return
*/
public int getWidth()
{
return maxX - minX;
}
/**
* Returns the height of the CuttingPart in Pixels
* @return
*/
public int getHeight()
{
return maxY - minY;
}
}