SankeyChartState.java

  1. /*
  2.  * Copyright 2014 James Pether Sörling
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  *
  8.  *   http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  *
  16.  *  $Id$
  17.  *  $HeadURL$
  18. */
  19. package com.hack23.cia.web.widgets.charts;

  20. import java.util.ArrayList;
  21. import java.util.List;

  22. import org.apache.commons.lang3.builder.EqualsBuilder;
  23. import org.apache.commons.lang3.builder.HashCodeBuilder;

  24. import com.vaadin.shared.ui.JavaScriptComponentState;

  25. /**
  26.  * The Class SankeyChartState.
  27.  */
  28. public final class SankeyChartState extends JavaScriptComponentState {

  29.     /** The Constant serialVersionUID. */
  30.     private static final long serialVersionUID = 1L;

  31.     /** The values. */
  32.     public List<List<Object>> values = new ArrayList<>();

  33.     /** The my id. */
  34.     public String myId;

  35.     /**
  36.      * Instantiates a new sankey chart state.
  37.      */
  38.     public SankeyChartState() {
  39.         super();
  40.     }

  41.     /**
  42.      * Adds the data row.
  43.      *
  44.      * @param from the from
  45.      * @param to the to
  46.      * @param weight the weight
  47.      */
  48.     public void addDataRow(final String from, final String to, int weight) {
  49.         final ArrayList<Object> valueData = new ArrayList<>();
  50.         valueData.add(from);
  51.         valueData.add(to);
  52.         valueData.add(weight);
  53.         values.add(valueData);
  54.     }

  55.     @Override
  56.     public int hashCode() {
  57.         return HashCodeBuilder.reflectionHashCode(this, false);
  58.     }

  59.     @Override
  60.     public boolean equals(Object obj) {
  61.         return EqualsBuilder.reflectionEquals(this, obj);
  62.     }

  63. }