提交 8730bc4b 编写于 作者: E Eduardo Ramos

Merge branch '0.9.0'

......@@ -536,7 +536,7 @@ public class AppearanceModelImpl implements AppearanceModel {
Set<Column> toRefreshColumns = new HashSet<Column>(forcedColumnsRefresh);
for (Column column : columns) {
if (!columnObservers.containsKey(column)) {
columnObservers.put(column, column.createColumnObserver());
columnObservers.put(column, column.createColumnObserver(false));
toRefreshColumns.add(column);
} else if (columnObservers.get(column).hasColumnChanged() || graphHasChanged) {
toRefreshColumns.add(column);
......
......@@ -54,6 +54,7 @@ import org.gephi.graph.api.Element;
import org.gephi.graph.api.Graph;
import org.gephi.graph.api.Node;
import org.gephi.graph.api.Table;
import org.gephi.graph.api.TimeRepresentation;
/**
* <p>This interface defines part of the Data Laboratory API basic actions.</p>
......@@ -124,22 +125,24 @@ public interface AttributeColumnsController {
/**
* <p>Converts and replaces a table column with a dynamic column preserving original column values.</p>
* <p>This should be used only in columns where the <code>canConvertColumnToDynamic</code> returns true</p>
* <p>The new values have a default interval that uses the low, high, lopen and ropen parameters.</p>
* <p>For graphs with {@code INTERVAL} {@link TimeRepresentation}, the new values have a default interval that uses the {@code low} and {@code high} parameters.</p>
* <p>For graphs with {@code TIMESTAMP} {@link TimeRepresentation}, the new values have a default timestamp that uses the {@code low} parameter, {@code high} parameter is ignored.</p>
* @param table Table of the column
* @param column Column to convert and replace
* @param low Low bound for default interval
* @param high High bound for default interval
* @param low Low bound for default interval or default timestamp
* @param high High bound for default interval or ignored for timestamps
* @return The new column
*/
Column convertAttributeColumnToDynamic(Table table, Column column, double low, double high);
/**
* <p>Converts a table column into a new dynamic column preserving original column values. The original column is kept intact</p>
* <p>The new values have a default interval that uses the low, high, lopen and ropen parameters.</p>
* <p>For graphs with {@code INTERVAL} {@link TimeRepresentation}, the new values have a default interval that uses the {@code low} and {@code high} parameters.</p>
* <p>For graphs with {@code TIMESTAMP} {@link TimeRepresentation}, the new values have a default timestamp that uses the {@code low} parameter, {@code high} parameter is ignored.</p>
* @param table Table of the column
* @param column Column to convert to dynamic
* @param low Low bound for default interval
* @param high High bound for default interval
* @param low Low bound for default interval or default timestamp
* @param high High bound for default interval or ignored for timestamps
* @param newColumnTitle Title for the new dynamic column
* @return The new column
*/
......
......@@ -69,7 +69,9 @@ import org.gephi.graph.api.Edge;
import org.gephi.graph.api.Element;
import org.gephi.graph.api.Graph;
import org.gephi.graph.api.GraphController;
import org.gephi.graph.api.Interval;
import org.gephi.graph.api.Node;
import org.gephi.graph.api.TimeRepresentation;
import org.gephi.graph.api.types.IntervalMap;
import org.gephi.graph.api.types.TimestampMap;
import org.gephi.utils.StatisticsUtils;
......@@ -156,7 +158,14 @@ public class AttributeColumnsControllerImpl implements AttributeColumnsControlle
private Column convertColumnToDynamic(Table table, Column column, double low, double high, String newColumnTitle) {
Class oldType = column.getTypeClass();
Class<? extends TimestampMap> newType = AttributeUtils.getTimestampMapType(oldType);
TimeRepresentation timeRepresentation = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getConfiguration().getTimeRepresentation();
Class<?> newType;
if (timeRepresentation == TimeRepresentation.TIMESTAMP) {
newType = AttributeUtils.getTimestampMapType(oldType);
} else {
newType = AttributeUtils.getIntervalMapType(oldType);
}
if (newColumnTitle != null) {
if (newColumnTitle.equals(column.getTitle())) {
......@@ -179,10 +188,18 @@ public class AttributeColumnsControllerImpl implements AttributeColumnsControlle
newColumn = table.addColumn(newColumnTitle, newType, column.getOrigin());
}
for (int i = 0; i < rows.length; i++) {
if (oldValues[i] != null) {
rows[i].setAttribute(newColumn, oldValues[i], low);
rows[i].setAttribute(newColumn, oldValues[i], high);
if (timeRepresentation == TimeRepresentation.TIMESTAMP) {
for (int i = 0; i < rows.length; i++) {
if (oldValues[i] != null) {
rows[i].setAttribute(newColumn, oldValues[i], low);
}
}
} else {
Interval interval = new Interval(low, high);
for (int i = 0; i < rows.length; i++) {
if (oldValues[i] != null) {
rows[i].setAttribute(newColumn, oldValues[i], interval);
}
}
}
......@@ -500,6 +517,15 @@ public class AttributeColumnsControllerImpl implements AttributeColumnsControlle
if (column.isReadOnly() || AttributeUtils.isDynamicType(column.getTypeClass())) {
return false;
}
try {
//Make sure the simple type can actually be part of a dynamic type of intervals/timestamps
//For example array types cannot be converted to dynamic
AttributeUtils.getIntervalMapType(column.getTypeClass());
AttributeUtils.getTimestampMapType(column.getTypeClass());
} catch (Exception e) {
return false;
}
if (isNodeColumn(column) || isEdgeColumn(column)) {
return !column.getTitle().equalsIgnoreCase("Label");
......
......@@ -44,6 +44,8 @@ package org.gephi.datalab.utils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.gephi.graph.api.AttributeUtils;
import org.gephi.graph.api.GraphModel;
import org.gephi.graph.api.TimeRepresentation;
......@@ -67,9 +69,11 @@ public class SupportedColumnTypeWrapper implements Comparable<SupportedColumnTyp
@Override
public String toString() {
String name = type.getSimpleName();
return name;
if (AttributeUtils.isArrayType(type)) {
return String.format("%s list", type.getComponentType().getSimpleName());
} else {
return type.getSimpleName();
}
}
public Class<?> getType() {
......@@ -142,6 +146,11 @@ public class SupportedColumnTypeWrapper implements Comparable<SupportedColumnTyp
TimeRepresentation timeRepresentation = graphModel.getConfiguration().getTimeRepresentation();
for (Class<?> type : AttributeUtils.getSupportedTypes()) {
if(type.equals(Map.class) || type.equals(List.class) || type.equals(Set.class)){
continue;
//Not yet supported in Gephi
}
if (AttributeUtils.isStandardizedType(type) && isTypeAvailable(type, timeRepresentation)) {
supportedTypesWrappers.add(new SupportedColumnTypeWrapper(type));
}
......
......@@ -45,9 +45,12 @@ import java.awt.Image;
import org.gephi.graph.api.Column;
import org.gephi.graph.api.Table;
import org.gephi.datalab.api.AttributeColumnsController;
import org.gephi.datalab.plugin.manipulators.columns.ui.ConvertColumnToDynamicTimestampsUI;
import org.gephi.datalab.plugin.manipulators.columns.ui.ConvertColumnToDynamicUI;
import org.gephi.datalab.spi.columns.AttributeColumnsManipulator;
import org.gephi.datalab.spi.columns.AttributeColumnsManipulatorUI;
import org.gephi.graph.api.GraphController;
import org.gephi.graph.api.TimeRepresentation;
import org.openide.util.ImageUtilities;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
......@@ -89,7 +92,13 @@ public class ConvertColumnToDynamic implements AttributeColumnsManipulator {
@Override
public AttributeColumnsManipulatorUI getUI(Table table, Column column) {
return new ConvertColumnToDynamicUI();
TimeRepresentation timeRepresentation = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getConfiguration().getTimeRepresentation();
if (timeRepresentation == TimeRepresentation.INTERVAL) {
return new ConvertColumnToDynamicUI();
} else {
return new ConvertColumnToDynamicTimestampsUI();
}
}
@Override
......
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="descriptionLabel" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Component id="replaceColumnCheckbox" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="titleLabel" min="-2" pref="61" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="titleTextField" pref="177" max="32767" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="timestampLabel" min="-2" pref="108" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="timestampText" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="descriptionLabel" min="-2" pref="23" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="timestampLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="timestampText" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="titleLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="titleTextField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="replaceColumnCheckbox" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="24" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="titleLabel">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/gephi/datalab/plugin/manipulators/columns/ui/Bundle.properties" key="ConvertColumnToDynamicTimestampsUI.titleLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="titleTextField">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/gephi/datalab/plugin/manipulators/columns/ui/Bundle.properties" key="ConvertColumnToDynamicTimestampsUI.titleTextField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="descriptionLabel">
<Properties>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="null" type="code"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="replaceColumnCheckbox">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/gephi/datalab/plugin/manipulators/columns/ui/Bundle.properties" key="ConvertColumnToDynamicTimestampsUI.replaceColumnCheckbox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/gephi/datalab/plugin/manipulators/columns/ui/Bundle.properties" key="ConvertColumnToDynamicTimestampsUI.replaceColumnCheckbox.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="horizontalTextPosition" type="int" value="10"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="replaceColumnCheckboxActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="timestampLabel">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/gephi/datalab/plugin/manipulators/columns/ui/Bundle.properties" key="ConvertColumnToDynamicTimestampsUI.timestampLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="timestampText">
</Component>
</SubComponents>
</Form>
/*
Copyright 2008-2010 Gephi
Authors : Eduardo Ramos <eduramiba@gmail.com>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2011 Gephi Consortium. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 3 only ("GPL") or the Common
Development and Distribution License("CDDL") (collectively, the
"License"). You may not use this file except in compliance with the
License. You can obtain a copy of the License at
http://gephi.org/about/legal/license-notice/
or /cddl-1.0.txt and /gpl-3.0.txt. See the License for the
specific language governing permissions and limitations under the
License. When distributing the software, include this License Header
Notice in each file and include the License files at
/cddl-1.0.txt and /gpl-3.0.txt. If applicable, add the following below the
License Header, with the fields enclosed by brackets [] replaced by
your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"
If you wish your version of this file to be governed by only the CDDL
or only the GPL Version 3, indicate your decision by adding
"[Contributor] elects to include this software in this distribution
under the [CDDL or GPL Version 3] license." If you do not indicate a
single choice of license, a recipient has the option to distribute
your version of this file under either the CDDL, the GPL Version 3 or
to extend the choice of license to its licensees as provided above.
However, if you add GPL Version 3 code and therefore, elected the GPL
Version 3 license, then the option applies only if the new code is
made subject to such option by the copyright holder.
Contributor(s):
Portions Copyrighted 2011 Gephi Consortium.
*/
package org.gephi.datalab.plugin.manipulators.columns.ui;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.gephi.graph.api.Column;
import org.gephi.graph.api.Table;
import org.gephi.datalab.plugin.manipulators.columns.ConvertColumnToDynamic;
import org.gephi.datalab.spi.DialogControls;
import org.gephi.datalab.spi.columns.AttributeColumnsManipulator;
import org.gephi.datalab.spi.columns.AttributeColumnsManipulatorUI;
import org.gephi.graph.api.AttributeUtils;
import org.gephi.graph.api.GraphModel;
import org.gephi.ui.utils.ColumnTitleValidator;
import org.gephi.ui.utils.IntervalBoundValidator;
import org.netbeans.validation.api.ui.ValidationGroup;
import org.netbeans.validation.api.ui.ValidationPanel;
import org.openide.util.NbBundle;
import org.openide.util.NbPreferences;
/**
* UI for ConvertColumnToDynamic AttributeColumnsManipulator and for <b>Timestamps</b>
*
* @author Eduardo Ramos
*/
public class ConvertColumnToDynamicTimestampsUI extends javax.swing.JPanel implements AttributeColumnsManipulatorUI {
private static final String TIMESTAMP_PREFERENCE = "ConvertColumnToDynamicTimestampsUI.intervalStart";
private static final String REPLACE_COLUMN_PREFERENCE = "ConvertColumnToDynamicTimestampsUI.replaceColumn";
private static final String DEFAULT_TIMESTAMP = "0";
private ConvertColumnToDynamic manipulator;
private Table table;
private DialogControls dialogControls;
private ValidationPanel validationPanel;
/**
* Creates new form DuplicateColumnUI
*/
public ConvertColumnToDynamicTimestampsUI() {
initComponents();
timestampText.setText(NbPreferences.forModule(ConvertColumnToDynamicTimestampsUI.class).get(TIMESTAMP_PREFERENCE, DEFAULT_TIMESTAMP));
replaceColumnCheckbox.setSelected(NbPreferences.forModule(ConvertColumnToDynamicTimestampsUI.class).getBoolean(REPLACE_COLUMN_PREFERENCE, false));
}
private void buildValidationPanel() {
validationPanel = new ValidationPanel();
validationPanel.setInnerComponent(this);
ValidationGroup group = validationPanel.getValidationGroup();
group.add(titleTextField, new ColumnTitleValidator(table));
group.add(timestampText, new IntervalBoundValidator());
validationPanel.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
dialogControls.setOkButtonEnabled(!validationPanel.isProblem());
}
});
}
@Override
public void setup(AttributeColumnsManipulator m, GraphModel graphModel, Table table, Column column, DialogControls dialogControls) {
this.table = table;
this.dialogControls = dialogControls;
this.manipulator = (ConvertColumnToDynamic) m;
buildValidationPanel();
descriptionLabel.setText(NbBundle.getMessage(ConvertColumnToDynamicTimestampsUI.class, "ConvertColumnToDynamicUI.descriptionLabel.text", column.getTitle()));
titleTextField.setText(NbBundle.getMessage(ConvertColumnToDynamicTimestampsUI.class, "ConvertColumnToDynamicUI.new.title", column.getTitle()));
refreshTitleEnabledState();
}
@Override
public void unSetup() {
String timestampString = timestampText.getText();
boolean replaceColumn = replaceColumnCheckbox.isSelected();
NbPreferences.forModule(ConvertColumnToDynamicTimestampsUI.class).put(TIMESTAMP_PREFERENCE, timestampString);
NbPreferences.forModule(ConvertColumnToDynamicTimestampsUI.class).putBoolean(REPLACE_COLUMN_PREFERENCE, replaceColumn);
if (!validationPanel.isProblem()) {
manipulator.setTitle(titleTextField.getText());
manipulator.setReplaceColumn(replaceColumn);
double timestamp = AttributeUtils.parseDateTimeOrTimestamp(timestampString);
manipulator.setLow(timestamp);
manipulator.setHigh(timestamp);
}
}
@Override
public String getDisplayName() {
return manipulator.getName();
}
@Override
public JPanel getSettingsPanel() {
return validationPanel;
}
@Override
public boolean isModal() {
return true;
}
private void refreshTitleEnabledState() {
boolean enabled = !replaceColumnCheckbox.isSelected();
titleTextField.setEnabled(enabled);
}
/**
* This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this method is always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
titleLabel = new javax.swing.JLabel();
titleTextField = new javax.swing.JTextField();
descriptionLabel = new javax.swing.JLabel();
replaceColumnCheckbox = new javax.swing.JCheckBox();
timestampLabel = new javax.swing.JLabel();
timestampText = new javax.swing.JTextField();
titleLabel.setText(org.openide.util.NbBundle.getMessage(ConvertColumnToDynamicTimestampsUI.class, "ConvertColumnToDynamicTimestampsUI.titleLabel.text")); // NOI18N
titleTextField.setText(org.openide.util.NbBundle.getMessage(ConvertColumnToDynamicTimestampsUI.class, "ConvertColumnToDynamicTimestampsUI.titleTextField.text")); // NOI18N
descriptionLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
descriptionLabel.setText(null);
replaceColumnCheckbox.setText(org.openide.util.NbBundle.getMessage(ConvertColumnToDynamicTimestampsUI.class, "ConvertColumnToDynamicTimestampsUI.replaceColumnCheckbox.text")); // NOI18N
replaceColumnCheckbox.setToolTipText(org.openide.util.NbBundle.getMessage(ConvertColumnToDynamicTimestampsUI.class, "ConvertColumnToDynamicTimestampsUI.replaceColumnCheckbox.toolTipText")); // NOI18N
replaceColumnCheckbox.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
replaceColumnCheckbox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
replaceColumnCheckboxActionPerformed(evt);
}
});
timestampLabel.setText(org.openide.util.NbBundle.getMessage(ConvertColumnToDynamicTimestampsUI.class, "ConvertColumnToDynamicTimestampsUI.timestampLabel.text")); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(descriptionLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(replaceColumnCheckbox)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(titleLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(titleTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 177, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(timestampLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(timestampText)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(descriptionLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(timestampLabel)
.addComponent(timestampText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(titleLabel)
.addComponent(titleTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(replaceColumnCheckbox))
.addGap(24, 24, 24))
);
}// </editor-fold>//GEN-END:initComponents
private void replaceColumnCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_replaceColumnCheckboxActionPerformed
refreshTitleEnabledState();
}//GEN-LAST:event_replaceColumnCheckboxActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel descriptionLabel;
private javax.swing.JCheckBox replaceColumnCheckbox;
private javax.swing.JLabel timestampLabel;
private javax.swing.JTextField timestampText;
private javax.swing.JLabel titleLabel;
private javax.swing.JTextField titleTextField;
// End of variables declaration//GEN-END:variables
}
......@@ -19,27 +19,25 @@
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="descriptionLabel" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="replaceColumnCheckbox" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="16" max="-2" attributes="0"/>
<Component id="titleLabel" min="-2" pref="30" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="titleTextField" pref="190" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="intervalEndLabel" max="32767" attributes="0"/>
<Component id="intervalStartLabel" pref="0" max="32767" attributes="0"/>
<Component id="intervalStartLabel" pref="117" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="intervalStartText" max="32767" attributes="0"/>
<Component id="intervalEndText" max="32767" attributes="0"/>
</Group>
</Group>
<Component id="descriptionLabel" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="replaceColumnCheckbox" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="filler1" min="-2" pref="4" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="titleLabel" min="-2" pref="30" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="titleTextField" pref="245" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
......@@ -51,23 +49,20 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="descriptionLabel" min="-2" pref="23" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="intervalStartLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="intervalStartText" alignment="3" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="intervalStartLabel" min="-2" max="-2" attributes="0"/>
<Component id="intervalStartText" min="-2" pref="20" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="intervalEndLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="intervalEndText" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="73" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="filler1" alignment="1" min="-2" pref="23" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="titleLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="titleTextField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="replaceColumnCheckbox" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="23" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="titleLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="titleTextField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="replaceColumnCheckbox" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="24" max="-2" attributes="0"/>
</Group>
......@@ -111,16 +106,6 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="replaceColumnCheckboxActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.Box$Filler" name="filler1">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[32767, 0]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.HorizontalGlue"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="intervalStartLabel">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
......@@ -129,11 +114,6 @@
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="intervalStartText">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/gephi/datalab/plugin/manipulators/columns/ui/Bundle.properties" key="ConvertColumnToDynamicUI.intervalStartText.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="intervalEndLabel">
<Properties>
......@@ -143,11 +123,6 @@
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="intervalEndText">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/gephi/datalab/plugin/manipulators/columns/ui/Bundle.properties" key="ConvertColumnToDynamicUI.intervalEndText.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Form>
......@@ -60,7 +60,7 @@ import org.openide.util.NbBundle;
import org.openide.util.NbPreferences;
/**
* UI for DuplicateColumn AttributeColumnsManipulator.
* UI for ConvertColumnToDynamic AttributeColumnsManipulator and for <b>Intervals</b>
*
* @author Eduardo Ramos
*/
......@@ -70,8 +70,8 @@ public class ConvertColumnToDynamicUI extends javax.swing.JPanel implements Attr
private static final String INTERVAL_END_PREFERENCE = "ConvertColumnToDynamicUI.intervalEnd";
private static final String REPLACE_COLUMN_PREFERENCE = "ConvertColumnToDynamicUI.replaceColumn";
private static final String DEFAULT_INTERVAL_START = "0";
private static final String DEFAULT_INTERVAL_END = "1.0";
private static final String DEFAULT_INTERVAL_START = "-Infinity";
private static final String DEFAULT_INTERVAL_END = "Infinity";
private ConvertColumnToDynamic manipulator;
private Table table;
......@@ -134,8 +134,8 @@ public class ConvertColumnToDynamicUI extends javax.swing.JPanel implements Attr
if (!validationPanel.isProblem()) {
manipulator.setTitle(titleTextField.getText());
manipulator.setReplaceColumn(replaceColumn);
manipulator.setLow(AttributeUtils.parseDateTime(intervalStart));
manipulator.setHigh(AttributeUtils.parseDateTime(intervalEnd));
manipulator.setLow(AttributeUtils.parseDateTimeOrTimestamp(intervalStart));
manipulator.setHigh(AttributeUtils.parseDateTimeOrTimestamp(intervalEnd));
}
}
......@@ -170,7 +170,6 @@ public class ConvertColumnToDynamicUI extends javax.swing.JPanel implements Attr
titleTextField = new javax.swing.JTextField();
descriptionLabel = new javax.swing.JLabel();
replaceColumnCheckbox = new javax.swing.JCheckBox();
filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 0));
intervalStartLabel = new javax.swing.JLabel();
intervalStartText = new javax.swing.JTextField();
intervalEndLabel = new javax.swing.JLabel();
......@@ -195,12 +194,8 @@ public class ConvertColumnToDynamicUI extends javax.swing.JPanel implements Attr
intervalStartLabel.setText(org.openide.util.NbBundle.getMessage(ConvertColumnToDynamicUI.class, "ConvertColumnToDynamicUI.intervalStartLabel.text")); // NOI18N
intervalStartText.setText(org.openide.util.NbBundle.getMessage(ConvertColumnToDynamicUI.class, "ConvertColumnToDynamicUI.intervalStartText.text")); // NOI18N
intervalEndLabel.setText(org.openide.util.NbBundle.getMessage(ConvertColumnToDynamicUI.class, "ConvertColumnToDynamicUI.intervalEndLabel.text")); // NOI18N
intervalEndText.setText(org.openide.util.NbBundle.getMessage(ConvertColumnToDynamicUI.class, "ConvertColumnToDynamicUI.intervalEndText.text")); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
......@@ -208,23 +203,21 @@ public class ConvertColumnToDynamicUI extends javax.swing.JPanel implements Attr
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(intervalEndLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(intervalStartLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(intervalStartText)
.addComponent(intervalEndText)))
.addComponent(descriptionLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(replaceColumnCheckbox)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(filler1, javax.swing.GroupLayout.PREFERRED_SIZE, 4, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGap(16, 16, 16)
.addComponent(titleLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(titleTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE)))
.addComponent(titleTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 190, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(intervalEndLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(intervalStartLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(intervalStartText)
.addComponent(intervalEndText))))
.addContainerGap())
);
layout.setVerticalGroup(
......@@ -233,20 +226,18 @@ public class ConvertColumnToDynamicUI extends javax.swing.JPanel implements Attr
.addContainerGap()
.addComponent(descriptionLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(intervalStartLabel)
.addComponent(intervalStartText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(intervalStartText, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(intervalEndLabel)
.addComponent(intervalEndText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 73, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(filler1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(titleLabel)
.addComponent(titleTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(replaceColumnCheckbox)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(titleLabel)
.addComponent(titleTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(replaceColumnCheckbox))
.addGap(24, 24, 24))
);
}// </editor-fold>//GEN-END:initComponents
......@@ -254,9 +245,9 @@ public class ConvertColumnToDynamicUI extends javax.swing.JPanel implements Attr
private void replaceColumnCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_replaceColumnCheckboxActionPerformed
refreshTitleEnabledState();
}//GEN-LAST:event_replaceColumnCheckboxActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel descriptionLabel;
private javax.swing.Box.Filler filler1;
private javax.swing.JLabel intervalEndLabel;
private javax.swing.JTextField intervalEndText;
private javax.swing.JLabel intervalStartLabel;
......
......@@ -25,12 +25,17 @@ NumberColumnStatisticsReportUI.divisionsLabel.text=Divisions:
ConvertColumnToDynamicUI.descriptionLabel.text=Convert column ''{0}'' to a dynamic column
ConvertColumnToDynamicUI.new.title={0}_dynamic
ConvertColumnToDynamicUI.titleLabel.text=Title:
ConvertColumnToDynamicUI.titleTextField.text=
ConvertColumnToDynamicUI.intervalOpenCheckbox.text=Open
ConvertColumnToDynamicUI.intervalStartLabel.text=Interval start:
ConvertColumnToDynamicUI.intervalStartText.text=-Infinity
ConvertColumnToDynamicUI.intervalEndLabel.text=Interval end:
ConvertColumnToDynamicUI.intervalEndText.text=Infinity
ConvertColumnToDynamicUI.replaceColumnCheckbox.text=Replace column
ConvertColumnToDynamicUI.replaceColumnCheckbox.toolTipText=Replace original column with dynamic column instead of creating a new one
ConvertColumnToDynamicUI.replaceColumnCheckbox.text=Replace column
ConvertColumnToDynamicUI.titleTextField.text=
ConvertColumnToDynamicUI.titleLabel.text=Title:
ConvertColumnToDynamicUI.intervalEndLabel.text=Interval end:
ConvertColumnToDynamicTimestampsUI.timestampLabel.text=Timestamp
ConvertColumnToDynamicTimestampsUI.replaceColumnCheckbox.text=Replace column
ConvertColumnToDynamicTimestampsUI.titleTextField.text=
ConvertColumnToDynamicTimestampsUI.titleLabel.text=Title:
ConvertColumnToDynamicTimestampsUI.replaceColumnCheckbox.toolTipText=Replace original column with dynamic column instead of creating a new one
......@@ -63,6 +63,7 @@ import org.gephi.desktop.datalab.utils.IntervalMapRenderer;
import org.gephi.desktop.datalab.utils.TimestampMapRenderer;
import org.gephi.desktop.datalab.utils.SparkLinesRenderer;
import org.gephi.desktop.datalab.utils.IntervalSetRenderer;
import org.gephi.desktop.datalab.utils.TimestampSetRenderer;
import org.gephi.graph.api.AttributeUtils;
import org.gephi.graph.api.Element;
import org.gephi.graph.api.GraphModel;
......@@ -71,6 +72,7 @@ import org.gephi.graph.api.TimeFormat;
import org.gephi.graph.api.types.IntervalMap;
import org.gephi.graph.api.types.IntervalSet;
import org.gephi.graph.api.types.TimestampMap;
import org.gephi.graph.api.types.TimestampSet;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.decorator.HighlighterFactory;
import org.joda.time.DateTimeZone;
......@@ -91,6 +93,7 @@ public abstract class AbstractElementsDataTable<T extends Element> {
protected Column[] showingColumns = null;
protected ElementsDataTableModel<T> model;
private final IntervalSetRenderer intervalSetRenderer;
private final TimestampSetRenderer timestampSetRenderer;
private final IntervalMapRenderer intervalMapRenderer;
private final TimestampMapRenderer timestampMapRenderer;
private final List<AttributeTypesSupportCellEditor> cellEditors = new ArrayList<AttributeTypesSupportCellEditor>();
......@@ -108,6 +111,7 @@ public abstract class AbstractElementsDataTable<T extends Element> {
table.setAutoCreateRowSorter(true);
sparkLinesRenderers = new ArrayList<SparkLinesRenderer>();
intervalSetRenderer = new IntervalSetRenderer();
timestampSetRenderer = new TimestampSetRenderer();
intervalMapRenderer = new IntervalMapRenderer();
timestampMapRenderer = new TimestampMapRenderer();
......@@ -135,6 +139,9 @@ public abstract class AbstractElementsDataTable<T extends Element> {
if (typeClass.equals(IntervalSet.class)) {
typeRenderer = intervalSetRenderer;
}
if (typeClass.equals(TimestampSet.class)) {
typeRenderer = timestampSetRenderer;
}
boolean isNumberType = AttributeUtils.isNumberType(typeClass);
......@@ -217,25 +224,8 @@ public abstract class AbstractElementsDataTable<T extends Element> {
Interval timeBounds = graphModel.getTimeBounds();
double min = timeBounds != null ? timeBounds.getLow() : Double.NEGATIVE_INFINITY;
double max = timeBounds != null ? timeBounds.getHigh() : Double.POSITIVE_INFINITY;
TimeFormat currentTimeFormat = graphModel.getTimeFormat();
DateTimeZone currentTimeZone = graphModel.getTimeZone();
for (SparkLinesRenderer sparkLinesRenderer : sparkLinesRenderers) {
sparkLinesRenderer.setTimeFormat(currentTimeFormat);
sparkLinesRenderer.setTimeZone(currentTimeZone);
}
intervalSetRenderer.setTimeFormat(currentTimeFormat);
intervalSetRenderer.setTimeZone(currentTimeZone);
intervalSetRenderer.setMinMax(min, max);
intervalMapRenderer.setTimeFormat(currentTimeFormat);
intervalMapRenderer.setTimeZone(currentTimeZone);
timestampMapRenderer.setTimeZone(currentTimeZone);
for (AttributeTypesSupportCellEditor cellEditor : cellEditors) {
cellEditor.setTimeFormat(currentTimeFormat);
cellEditor.setTimeZone(currentTimeZone);
}
refreshCellRenderersAndEditorsConfiguration(graphModel, min, max);
refreshingTable = true;
if (selectedElements == null) {
......@@ -260,6 +250,35 @@ public abstract class AbstractElementsDataTable<T extends Element> {
refreshingTable = false;
}
private void refreshCellRenderersAndEditorsConfiguration(GraphModel graphModel, double min, double max) {
TimeFormat currentTimeFormat = graphModel.getTimeFormat();
DateTimeZone currentTimeZone = graphModel.getTimeZone();
for (SparkLinesRenderer sparkLinesRenderer : sparkLinesRenderers) {
sparkLinesRenderer.setTimeFormat(currentTimeFormat);
sparkLinesRenderer.setTimeZone(currentTimeZone);
}
intervalSetRenderer.setTimeFormat(currentTimeFormat);
intervalSetRenderer.setTimeZone(currentTimeZone);
intervalSetRenderer.setMinMax(min, max);
timestampSetRenderer.setTimeFormat(currentTimeFormat);
timestampSetRenderer.setTimeZone(currentTimeZone);
timestampSetRenderer.setMinMax(min, max);
intervalMapRenderer.setTimeFormat(currentTimeFormat);
intervalMapRenderer.setTimeZone(currentTimeZone);
timestampMapRenderer.setTimeZone(currentTimeZone);
for (AttributeTypesSupportCellEditor cellEditor : cellEditors) {
cellEditor.setTimeFormat(currentTimeFormat);
cellEditor.setTimeZone(currentTimeZone);
}
}
public boolean isRefreshingTable() {
return refreshingTable;
}
......@@ -302,22 +321,15 @@ public abstract class AbstractElementsDataTable<T extends Element> {
return table.getRowCount() > 0;
}
public boolean isDrawSparklines() {
return sparkLinesRenderers.get(0).isDrawGraphics();
}
public void setDrawSparklines(boolean drawSparklines) {
for (SparkLinesRenderer sparkLinesRenderer : sparkLinesRenderers) {
sparkLinesRenderer.setDrawGraphics(drawSparklines);
}
}
public boolean isDrawTimeIntervalGraphics() {
return intervalSetRenderer.isDrawGraphics();
}
public void setDrawTimeIntervalGraphics(boolean drawTimeIntervalGraphics) {
intervalSetRenderer.setDrawGraphics(drawTimeIntervalGraphics);
timestampSetRenderer.setDrawGraphics(drawTimeIntervalGraphics);
}
public T getElementFromRow(int row) {
......
/*
Copyright 2008-2010 Gephi
Authors : Eduardo Ramos
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2011 Gephi Consortium. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 3 only ("GPL") or the Common
Development and Distribution License("CDDL") (collectively, the
"License"). You may not use this file except in compliance with the
License. You can obtain a copy of the License at
http://gephi.org/about/legal/license-notice/
or /cddl-1.0.txt and /gpl-3.0.txt. See the License for the
specific language governing permissions and limitations under the
License. When distributing the software, include this License Header
Notice in each file and include the License files at
/cddl-1.0.txt and /gpl-3.0.txt. If applicable, add the following below the
License Header, with the fields enclosed by brackets [] replaced by
your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"
If you wish your version of this file to be governed by only the CDDL
or only the GPL Version 3, indicate your decision by adding
"[Contributor] elects to include this software in this distribution
under the [CDDL or GPL Version 3] license." If you do not indicate a
single choice of license, a recipient has the option to distribute
your version of this file under either the CDDL, the GPL Version 3 or
to extend the choice of license to its licensees as provided above.
However, if you add GPL Version 3 code and therefore, elected the GPL
Version 3 license, then the option applies only if the new code is
made subject to such option by the copyright holder.
Contributor(s):
Portions Copyrighted 2011 Gephi Consortium.
*/
package org.gephi.desktop.datalab.utils;
import java.awt.Color;
import java.awt.Component;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import org.gephi.graph.api.TimeFormat;
import org.gephi.graph.api.types.TimestampSet;
import org.gephi.utils.TimeIntervalGraphics;
import org.joda.time.DateTimeZone;
/**
* TableCellRenderer for drawing time intervals graphics from cells that have a {@link TimestampSet} as their value.
*
* @author Eduardo Ramos
*/
public class TimestampSetRenderer extends DefaultTableCellRenderer {
private static final Color SELECTED_BACKGROUND = new Color(225, 255, 255);
private static final Color UNSELECTED_BACKGROUND = Color.white;
private static final Color FILL_COLOR = new Color(153, 255, 255);
private static final Color BORDER_COLOR = new Color(2, 104, 255);
private boolean drawGraphics = false;
private final TimeIntervalGraphics timeIntervalGraphics;
private TimeFormat timeFormat = TimeFormat.DOUBLE;
private DateTimeZone timeZone = DateTimeZone.UTC;
public TimestampSetRenderer() {
this(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
}
public TimestampSetRenderer(double min, double max) {
timeIntervalGraphics = new TimeIntervalGraphics(min, max);
}
public TimestampSetRenderer(double min, double max, boolean drawGraphics) {
timeIntervalGraphics = new TimeIntervalGraphics(min, max);
this.drawGraphics = drawGraphics;
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (value == null) {
//Render empty string when null
return super.getTableCellRendererComponent(table, null, isSelected, hasFocus, row, column);
}
TimestampSet timestampSet = (TimestampSet) value;
String stringRepresentation = timestampSet.toString(timeFormat, timeZone);
if (drawGraphics) {
JLabel label = new JLabel();
Color background;
if (isSelected) {
background = SELECTED_BACKGROUND;
} else {
background = UNSELECTED_BACKGROUND;
}
double[] timestamps = timestampSet.toPrimitiveArray();
double starts[] = new double[timestamps.length];
double ends[] = new double[timestamps.length];
for (int i = 0; i < timestamps.length; i++) {
starts[i] = timestamps[i];
ends[i] = timestamps[i];
}
final BufferedImage i = timeIntervalGraphics.createTimeIntervalImage(starts, ends, table.getColumnModel().getColumn(column).getWidth() - 1, table.getRowHeight(row) - 1, FILL_COLOR, BORDER_COLOR, background);
label.setIcon(new ImageIcon(i));
label.setToolTipText(stringRepresentation);//String representation as tooltip
return label;
} else {
return super.getTableCellRendererComponent(table, stringRepresentation, isSelected, hasFocus, row, column);
}
}
public boolean isDrawGraphics() {
return drawGraphics;
}
public void setDrawGraphics(boolean drawGraphics) {
this.drawGraphics = drawGraphics;
}
public TimeFormat getTimeFormat() {
return timeFormat;
}
public void setTimeFormat(TimeFormat timeFormat) {
this.timeFormat = timeFormat;
}
public DateTimeZone getTimeZone() {
return timeZone;
}
public void setTimeZone(DateTimeZone timeZone) {
this.timeZone = timeZone;
}
public double getMax() {
return timeIntervalGraphics.getMax();
}
public void setMax(double max) {
timeIntervalGraphics.setMax(max);
}
public double getMin() {
return timeIntervalGraphics.getMin();
}
public void setMin(double min) {
timeIntervalGraphics.setMin(min);
}
public void setMinMax(double min, double max) {
timeIntervalGraphics.setMin(min);
timeIntervalGraphics.setMax(max);
}
}
......@@ -47,9 +47,7 @@ import org.netbeans.validation.api.Validator;
import org.openide.util.NbBundle;
/**
* Utils class to validate a string that contains a valid title for a column of
* a
* <code>AttributeTable</code>.
* Utils class to validate a string that contains a valid title for a column of a {@link Table}
*
* @author Eduardo Ramos
*/
......
......@@ -41,7 +41,6 @@
*/
package org.gephi.ui.utils;
import java.text.ParseException;
import javax.swing.text.JTextComponent;
import org.gephi.graph.api.AttributeUtils;
import org.netbeans.validation.api.Problems;
......@@ -49,14 +48,15 @@ import org.netbeans.validation.api.Validator;
import org.openide.util.NbBundle;
/**
* Utils class to validate a string that contains a valid title for a column of
* a
* <code>AttributeTable</code>.
* Utils class to validate a single timestamp/datetime or an interval of a start and end timestamp/datetime.
*
* @author Eduardo Ramos
*/
public class IntervalBoundValidator implements Validator<String> {
/**
* If not null, interval start <= end is also validated.
*/
private JTextComponent intervalStartTextField = null;
public IntervalBoundValidator() {
......@@ -69,11 +69,11 @@ public class IntervalBoundValidator implements Validator<String> {
@Override
public boolean validate(Problems prblms, String componentName, String value) {
try {
double time = AttributeUtils.parseDateTime(value);
double time = AttributeUtils.parseDateTimeOrTimestamp(value);
if (intervalStartTextField != null) {
//Also validate that this (end time) is greater or equal than start time.
try {
double startTime = AttributeUtils.parseDateTime(intervalStartTextField.getText());
double startTime = AttributeUtils.parseDateTimeOrTimestamp(intervalStartTextField.getText());
if (time < startTime) {
prblms.add(NbBundle.getMessage(IntervalBoundValidator.class, "IntervalBoundValidator.invalid.interval.message"));
return false;
......
......@@ -297,7 +297,7 @@ public class DataBridge implements VizArchitecture {
nodeColumnHashCode = Arrays.hashCode(nodeColumns);
nodeColumnObservers = new ColumnObserver[nodeColumns.length];
for (int i = 0; i < nodeColumns.length; i++) {
nodeColumnObservers[i] = nodeColumns[i].createColumnObserver();
nodeColumnObservers[i] = nodeColumns[i].createColumnObserver(false);
}
}
......@@ -314,7 +314,7 @@ public class DataBridge implements VizArchitecture {
edgeColumnHashCode = Arrays.hashCode(edgeColumns);
edgeColumnObservers = new ColumnObserver[edgeColumns.length];
for (int i = 0; i < edgeColumns.length; i++) {
edgeColumnObservers[i] = edgeColumns[i].createColumnObserver();
edgeColumnObservers[i] = edgeColumns[i].createColumnObserver(false);
}
}
......
......@@ -134,7 +134,7 @@
<netbeans.version>RELEASE81</netbeans.version>
<!-- Graphstore version -->
<graphstore.version>0.4.9</graphstore.version>
<graphstore.version>0.5.0</graphstore.version>
<!-- Localization ZIP version, from 'http://netbeans.org/project_downloads/nblocalization' -->
<gephi.platform.localization.version>1.1-NB80</gephi.platform.localization.version>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册