public ColumnEstimator(Column column) { this.column = column; this.comboBox = new JComboBox(); this.label = new JLabel(column.getTitle()); initAvailableEstimators(); Estimator currentEstimator = column.getEstimator(); comboBox.setSelectedItem(new EstimatorWrapper(currentEstimator)); }
@Override public double getWeight(GraphView view) { synchronized (this) { Object value = attributes[GraphStoreConfiguration.EDGE_WEIGHT_INDEX]; if (value instanceof TimeMap) { Interval interval = view.getTimeInterval(); checkViewExist((GraphView) view); TimeMap dynamicValue = (TimeMap) value; Estimator estimator = getColumnStore().getColumnByIndex(GraphStoreConfiguration.EDGE_WEIGHT_INDEX) .getEstimator(); if (estimator == null) { estimator = GraphStoreConfiguration.DEFAULT_ESTIMATOR; } Double doubleVal = (Double) dynamicValue.get(interval, estimator); return doubleVal != null ? doubleVal : DEFAULT_DYNAMIC_EDGE_WEIGHT_WHEN_MISSING; } else if (value == null) { return DEFAULT_DYNAMIC_EDGE_WEIGHT_WHEN_MISSING; } else { // Must be double return (Double) value; } } }
@Override public double getWeight(GraphView view) { synchronized (this) { Object value = attributes[GraphStoreConfiguration.EDGE_WEIGHT_INDEX]; if (value instanceof TimeMap) { Interval interval = view.getTimeInterval(); checkViewExist((GraphView) view); TimeMap dynamicValue = (TimeMap) value; Estimator estimator = getColumnStore().getColumnByIndex(GraphStoreConfiguration.EDGE_WEIGHT_INDEX) .getEstimator(); if (estimator == null) { estimator = GraphStoreConfiguration.DEFAULT_ESTIMATOR; } Double doubleVal = (Double) dynamicValue.get(interval, estimator); return doubleVal != null ? doubleVal : DEFAULT_DYNAMIC_EDGE_WEIGHT_WHEN_MISSING; } else if (value == null) { return DEFAULT_DYNAMIC_EDGE_WEIGHT_WHEN_MISSING; } else { // Must be double return (Double) value; } } }
@Override public Object getAttribute(Column column, GraphView view) { checkColumn(column); if (!column.isDynamic()) { return getAttribute(column); } else { Interval interval = view.getTimeInterval(); checkViewExist((GraphView) view); int index = column.getIndex(); synchronized (this) { TimeMap dynamicValue = null; if (index < attributes.length) { dynamicValue = (TimeMap) attributes[index]; } if (dynamicValue != null && !dynamicValue.isEmpty()) { Estimator estimator = column.getEstimator(); if (estimator == null) { estimator = GraphStoreConfiguration.DEFAULT_ESTIMATOR; } return dynamicValue.get(interval, estimator); } } } return null; }
@Override public Object getAttribute(Column column, GraphView view) { checkColumn(column); if (!column.isDynamic()) { return getAttribute(column); } else { Interval interval = view.getTimeInterval(); checkViewExist((GraphView) view); int index = column.getIndex(); synchronized (this) { TimeMap dynamicValue = null; if (index < attributes.length) { dynamicValue = (TimeMap) attributes[index]; } if (dynamicValue != null && !dynamicValue.isEmpty()) { Estimator estimator = column.getEstimator(); if (estimator == null) { estimator = GraphStoreConfiguration.DEFAULT_ESTIMATOR; } return dynamicValue.get(interval, estimator); } } } return null; }