Newer
Older
* This file is part of LibLaserCut.
* Copyright (C) 2011 - 2013 Thomas Oster <thomas.oster@rwth-aachen.de>
* RWTH Aachen University - 52062 Aachen, Germany
*
* LibLaserCut 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.
*
* LibLaserCut 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 LibLaserCut. If not, see <http://www.gnu.org/licenses/>.
**/
package com.t_oster.liblasercut.drivers;
import com.t_oster.liblasercut.FloatPowerSpeedFocusFrequencyProperty;
Thomas Oster
committed
import java.util.Arrays;
import java.util.LinkedList;
/**
*
* @author Thomas Oster <thomas.oster@rwth-aachen.de>
*/
public class LaosCutterProperty extends FloatPowerSpeedFocusFrequencyProperty {
Thomas Oster
committed
private boolean hidePurge = false;
private boolean hideVentilation = false;
Thomas Oster
committed
private boolean hideFocus = false;
private boolean hideFrequency = false;
Thomas Oster
committed
private boolean ventilation = true;
public LaosCutterProperty(boolean hidePurge, boolean hideVentilation, boolean hideFocus, boolean hideFrequency)
Thomas Oster
committed
{
this.hidePurge = hidePurge;
this.hideVentilation = hideVentilation;
Thomas Oster
committed
this.hideFocus = hideFocus;
Thomas Oster
committed
}
public LaosCutterProperty()
{
Thomas Oster
committed
}
51
52
53
54
55
56
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
/**
* Get the value of ventilation
*
* @return the value of ventilation
*/
public boolean getVentilation()
{
return ventilation;
}
/**
* Set the value of ventilation
*
* @param ventilation new value of ventilation
*/
public void setVentilation(boolean ventilation)
{
this.ventilation = ventilation;
}
private boolean purge = true;
/**
* Get the value of purge
*
* @return the value of purge
*/
public boolean getPurge()
{
return purge;
}
/**
* Set the value of purge
*
* @param purge new value of purge
*/
public void setPurge(boolean purge)
{
this.purge = purge;
}
@Override
Thomas Oster
committed
public String[] getPropertyKeys()
Thomas Oster
committed
LinkedList<String> result = new LinkedList<String>();
result.addAll(Arrays.asList(super.getPropertyKeys()));
if (this.hideFocus)
Thomas Oster
committed
{
Thomas Oster
committed
result.remove("focus");
Thomas Oster
committed
}
if (this.hideFrequency)
{
result.remove("frequency");
}
Thomas Oster
committed
if (!this.hideVentilation)
{
Thomas Oster
committed
result.add("ventilation");
Thomas Oster
committed
}
if (!this.hidePurge)
{
Thomas Oster
committed
result.add("purge");
Thomas Oster
committed
}
Thomas Oster
committed
return result.toArray(new String[0]);
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
}
@Override
public Object getProperty(String name)
{
if ("ventilation".equals(name))
{
return (Boolean) this.getVentilation();
}
else if ("purge".equals(name))
{
return (Boolean) this.getPurge();
}
else
{
return super.getProperty(name);
}
}
@Override
public void setProperty(String name, Object value)
{
if ("ventilation".equals(name))
{
this.setVentilation((Boolean) value);
}
else if ("purge".equals(name))
{
this.setPurge((Boolean) value);
}
else
{
super.setProperty(name, value);
}
}
@Override
public LaosCutterProperty clone()
{
LaosCutterProperty result = new LaosCutterProperty();
Thomas Oster
committed
for (String s:this.getPropertyKeys())
{
result.setProperty(s, this.getProperty(s));
}
return result;
}
Max Gaukler
committed
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final LaosCutterProperty other = (LaosCutterProperty) obj;
if (this.ventilation != other.ventilation) {
return false;
}
if (this.purge != other.purge) {
return false;
}
return super.equals(other);
}
@Override
public int hashCode() {
int hash = 5;
hash = 97 * hash + (this.ventilation ? 1 : 0);
hash = 97 * hash + (this.purge ? 1 : 0);
hash = 97 * hash + super.hashCode();
return hash;
}