From: <be...@us...> - 2009-06-22 11:38:00
|
Revision: 135 http://jtreemap.svn.sourceforge.net/jtreemap/?rev=135&view=rev Author: benoitx Date: 2009-06-22 11:37:58 +0000 (Mon, 22 Jun 2009) Log Message: ----------- Adding a new FormatterValue which can use a NumberFormat for the label. Modified Paths: -------------- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultValue.java trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/Value.java Added Paths: ----------- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/FormattedValue.java Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultValue.java =================================================================== --- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultValue.java 2009-06-12 20:19:50 UTC (rev 134) +++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/DefaultValue.java 2009-06-22 11:37:58 UTC (rev 135) @@ -39,9 +39,6 @@ * @author Laurent DUTHEIL */ public class DefaultValue extends Value { - /** - * - */ private static final long serialVersionUID = 367321198951855282L; private double value; Added: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/FormattedValue.java =================================================================== --- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/FormattedValue.java (rev 0) +++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/FormattedValue.java 2009-06-22 11:37:58 UTC (rev 135) @@ -0,0 +1,86 @@ +/* + * ObjectLab, http://www.objectlab.co.uk/open is supporting JTreeMap. + * + * Based in London, we are world leaders in the design and development + * of bespoke applications for the securities financing markets. + * + * <a href="http://www.objectlab.co.uk/open">Click here to learn more</a> + * ___ _ _ _ _ _ + * / _ \| |__ (_) ___ ___| |_| | __ _| |__ + * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \ + * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) | + * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/ + * |__/ + * + * www.ObjectLab.co.uk + * + * $Id: ColorProvider.java 69 2006-10-24 16:20:20Z benoitx $ + * + * Copyright 2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package net.sf.jtreemap.swing; + +import java.math.BigDecimal; +import java.text.NumberFormat; + +/** + * class who can display the values of elements of a JTreeMap with a formatter. + * + * @author Benoit Xhenseval + */ + +public class FormattedValue extends DefaultValue { + private static final long serialVersionUID = 108728719010392928L; + private final NumberFormat nf; + + public FormattedValue() { + this(null); + } + + public FormattedValue(final NumberFormat nf) { + this(nf, null); + } + + public FormattedValue(final NumberFormat nf, final double value) { + super(value); + this.nf = nf; + } + + public FormattedValue(final NumberFormat nf, final BigDecimal value) { + super(value != null ? value.doubleValue() : 0.0); + this.nf = nf; + } + + @Override + public String getLabel() { + return nf != null ? nf.format(getValue()) : String.valueOf(getValue()); + } +} +/* + * ObjectLab is supporing JTreeMap + * + * Based in London, we are world leaders in the design and development + * of bespoke applications for the securities financing markets. + * + * <a href="http://www.objectlab.co.uk/open">Click here to learn more about us</a> + * ___ _ _ _ _ _ + * / _ \| |__ (_) ___ ___| |_| | __ _| |__ + * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \ + * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) | + * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/ + * |__/ + * + * www.ObjectLab.co.uk + */ Modified: trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/Value.java =================================================================== --- trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/Value.java 2009-06-12 20:19:50 UTC (rev 134) +++ trunk/JTreeMap/src/main/java/net/sf/jtreemap/swing/Value.java 2009-06-22 11:37:58 UTC (rev 135) @@ -41,9 +41,6 @@ */ public abstract class Value implements Comparable, Serializable { - /** - * - */ private static final long serialVersionUID = 1L; private static final int SHIFT = 32; private static final int PRIME = 31; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |