2
Copyright 2008-2010 Gephi
3
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
4
Website : http://www.gephi.org
6
This file is part of Gephi.
8
Gephi is free software: you can redistribute it and/or modify
9
it under the terms of the GNU Affero General Public License as
10
published by the Free Software Foundation, either version 3 of the
11
License, or (at your option) any later version.
13
Gephi is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU Affero General Public License for more details.
18
You should have received a copy of the GNU Affero General Public License
19
along with Gephi. If not, see <http://www.gnu.org/licenses/>.
21
package org.gephi.filters;
23
import java.beans.PropertyEditorSupport;
24
import org.gephi.filters.api.Range;
28
* @author Mathieu Bastian
30
public class RangePropertyEditor extends PropertyEditorSupport {
35
public void setValue(Object value) {
36
this.range = (Range) value;
40
public Object getValue() {
45
public String getAsText() {
47
return range.getRangeType().getSimpleName() + " - " + range.toString();
54
public void setAsText(String text) throws IllegalArgumentException {
55
if (!text.equals("null")) {
56
String[] arr = text.split(" - ");
57
if (arr[0].equals("Float")) {
58
range = new Range(Float.parseFloat(arr[1]), Float.parseFloat(arr[2]));
59
} else if (arr[0].equals("Double")) {
60
range = new Range(Double.parseDouble(arr[1]), Double.parseDouble(arr[2]));
61
} else if (arr[0].equals("Integer")) {
62
range = new Range(Integer.parseInt(arr[1]), Integer.parseInt(arr[2]));
63
} else if (arr[0].equals("Long")) {
64
range = new Range(Long.parseLong(arr[1]), Long.parseLong(arr[2]));