Implement appearance center panel system for partition

Esse commit está contido em:
Mathieu Bastian
2013-07-28 19:24:35 -07:00
commit 3ecaa139a6
101 arquivos alterados com 3029 adições e 607 exclusões
@@ -1,6 +1,43 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.appearance;
@@ -1,12 +1,70 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.appearance;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.gephi.appearance.api.AppearanceModel;
import org.gephi.appearance.api.AttributeFunction;
import org.gephi.appearance.api.Function;
import org.gephi.appearance.api.Interpolator;
import org.gephi.appearance.spi.PartitionTransformer;
import org.gephi.appearance.spi.RankingTransformer;
import org.gephi.appearance.spi.SimpleTransformer;
import org.gephi.appearance.spi.Transformer;
import org.gephi.appearance.spi.TransformerUI;
import org.gephi.attribute.api.AttributeModel;
import org.gephi.attribute.api.AttributeUtils;
import org.gephi.attribute.api.Column;
import org.gephi.attribute.api.Index;
import org.gephi.graph.api.GraphController;
import org.gephi.graph.api.GraphModel;
import org.gephi.project.api.Workspace;
import org.openide.util.Lookup;
/**
*
@@ -15,12 +73,24 @@ import org.gephi.project.api.Workspace;
public class AppearanceModelImpl implements AppearanceModel {
private final Workspace workspace;
private final AttributeModel attributeModel;
private final GraphModel graphModel;
private Interpolator interpolator;
private boolean localScale = false;
//Functions
private final Object functionLock;
private List<Function> nodeFunctions;
private List<Function> edgeFunctions;
public AppearanceModelImpl(Workspace workspace) {
this.workspace = workspace;
this.graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel(workspace);
this.attributeModel = Lookup.getDefault().lookup(GraphController.class).getAttributeModel(workspace);
this.interpolator = Interpolator.LINEAR;
this.functionLock = new Object();
//Functions
refreshFunctions();
}
@Override
@@ -28,6 +98,155 @@ public class AppearanceModelImpl implements AppearanceModel {
return interpolator;
}
@Override
public Workspace getWorkspace() {
return workspace;
}
@Override
public boolean isLocalScale() {
return localScale;
}
@Override
public Function[] getNodeFunctions() {
refreshFunctions();
return nodeFunctions.toArray(new Function[0]);
}
@Override
public Function[] getEdgeFunctions() {
refreshFunctions();
return edgeFunctions.toArray(new Function[0]);
}
private void refreshFunctions() {
synchronized (functionLock) {
//Index UIs
Map<Class, TransformerUI> uis = new HashMap<Class, TransformerUI>();
for (TransformerUI ui : Lookup.getDefault().lookupAll(TransformerUI.class)) {
Class transformerClass = ui.getTransformerClass();
if (transformerClass == null) {
throw new NullPointerException("Transformer class can' be null");
}
if (uis.containsKey(transformerClass)) {
throw new RuntimeException("A Transformer can't be attach to multiple TransformerUI");
}
uis.put(transformerClass, ui);
}
//Index existing funcs
Set<Column> attributeNodeFunctions = new HashSet<Column>();
Set<Column> attributeEdgeFunctions = new HashSet<Column>();
if (nodeFunctions != null) {
for (Function f : nodeFunctions) {
if (f.isAttribute()) {
attributeNodeFunctions.add(((AttributeFunction) f).getColumn());
}
}
}
if (edgeFunctions != null) {
for (Function f : edgeFunctions) {
if (f.isAttribute()) {
attributeEdgeFunctions.add(((AttributeFunction) f).getColumn());;
}
}
}
//Simple transformers
if (nodeFunctions == null) {
nodeFunctions = new ArrayList<Function>();
edgeFunctions = new ArrayList<Function>();
for (Transformer transformer : Lookup.getDefault().lookupAll(Transformer.class)) {
if (transformer instanceof SimpleTransformer) {
if (transformer.isNode()) {
nodeFunctions.add(new FunctionImpl(this, null, transformer, uis.get(transformer.getClass())));
}
if (transformer.isEdge()) {
edgeFunctions.add(new FunctionImpl(this, null, transformer, uis.get(transformer.getClass())));
}
}
}
}
//Atts
for (Transformer transformer : Lookup.getDefault().lookupAll(Transformer.class)) {
if (transformer instanceof RankingTransformer || transformer instanceof PartitionTransformer) {
if (transformer.isNode()) {
for (Column col : attributeModel.getNodeTable()) {
if (!col.isProperty() && col.isNumber()) {
Index index = localScale ? graphModel.getNodeIndex(graphModel.getVisibleView()) : graphModel.getNodeIndex();
if (transformer instanceof RankingTransformer && isRanking(col) && !attributeNodeFunctions.contains(col)) {
nodeFunctions.add(new FunctionImpl(this, col, transformer, uis.get(transformer.getClass())));
} else if (transformer instanceof PartitionTransformer && isPartition(col) && !attributeNodeFunctions.contains(col)) {
nodeFunctions.add(new FunctionImpl(this, col, transformer, uis.get(transformer.getClass()), new PartitionImpl(col, index)));
}
attributeNodeFunctions.remove(col);
}
}
}
if (transformer.isEdge()) {
for (Column col : attributeModel.getNodeTable()) {
if (!col.isProperty() && col.isNumber()) {
Index index = localScale ? graphModel.getEdgeIndex(graphModel.getVisibleView()) : graphModel.getEdgeIndex();
if (transformer instanceof RankingTransformer && isRanking(col) && !attributeEdgeFunctions.contains(col)) {
edgeFunctions.add(new FunctionImpl(this, col, transformer, uis.get(transformer.getClass())));
} else if (transformer instanceof PartitionTransformer && isPartition(col) && !attributeEdgeFunctions.contains(col)) {
edgeFunctions.add(new FunctionImpl(this, col, transformer, uis.get(transformer.getClass()), new PartitionImpl(col, index)));
}
attributeEdgeFunctions.remove(col);
}
}
}
}
}
//Remove
for (Iterator<Function> nodeItr = nodeFunctions.iterator(); nodeItr.hasNext();) {
Function f = nodeItr.next();
if (f.isAttribute() && attributeNodeFunctions.contains(((AttributeFunction) f).getColumn())) {
nodeItr.remove();
}
}
for (Iterator<Function> edgeItr = edgeFunctions.iterator(); edgeItr.hasNext();) {
Function f = edgeItr.next();
if (f.isAttribute() && attributeEdgeFunctions.contains(((AttributeFunction) f).getColumn())) {
edgeItr.remove();
}
}
}
}
public boolean isPartition(Column column) {
Index index;
if (AttributeUtils.isNodeColumn(column)) {
index = localScale ? graphModel.getNodeIndex(graphModel.getVisibleView()) : graphModel.getNodeIndex();
} else {
index = localScale ? graphModel.getEdgeIndex(graphModel.getVisibleView()) : graphModel.getEdgeIndex();
}
int valueCount = index.countValues(column);
int elementCount = index.countElements(column);
double ratio = valueCount / (double) elementCount;
if (ratio < 0.9) {
return true;
}
return false;
}
public boolean isRanking(Column column) {
Index index;
if (AttributeUtils.isNodeColumn(column)) {
index = localScale ? graphModel.getNodeIndex(graphModel.getVisibleView()) : graphModel.getNodeIndex();
} else {
index = localScale ? graphModel.getEdgeIndex(graphModel.getVisibleView()) : graphModel.getEdgeIndex();
}
if (index.countValues(column) > 0 && !isPartition(column)) {
return true;
}
return false;
}
public void setInterpolator(Interpolator interpolator) {
if (interpolator == null) {
throw new NullPointerException();
@@ -35,17 +254,11 @@ public class AppearanceModelImpl implements AppearanceModel {
this.interpolator = interpolator;
}
@Override
public Workspace getWorkspace() {
return workspace;
}
@Override
public boolean useLocalScale() {
return localScale;
}
public void setLocalScale(boolean localScale) {
this.localScale = localScale;
}
protected GraphModel getGraphModel() {
return graphModel;
}
}
@@ -0,0 +1,142 @@
/*
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.appearance;
import org.gephi.appearance.api.Partition;
import org.gephi.appearance.api.PartitionFunction;
import org.gephi.appearance.api.RankingFunction;
import org.gephi.appearance.api.SimpleFunction;
import org.gephi.appearance.spi.SimpleTransformer;
import org.gephi.appearance.spi.Transformer;
import org.gephi.appearance.spi.TransformerUI;
import org.gephi.attribute.api.Column;
import org.gephi.graph.api.Element;
/**
*
* @author mbastian
*/
public class FunctionImpl implements RankingFunction, PartitionFunction, SimpleFunction {
protected final AppearanceModelImpl model;
protected final Column column;
protected final Transformer transformer;
protected final TransformerUI transformerUI;
protected final PartitionImpl partition;
public FunctionImpl(AppearanceModelImpl model, Column column, Transformer transformer, TransformerUI transformerUI) {
this(model, column, transformer, transformerUI, null);
}
public FunctionImpl(AppearanceModelImpl model, Column column, Transformer transformer, TransformerUI transformerUI, PartitionImpl partition) {
this.model = model;
this.column = column;
try {
this.transformer = transformer.getClass().newInstance();
} catch (Exception ex) {
throw new RuntimeException(ex);
}
this.transformerUI = transformerUI;
this.partition = partition;
}
@Override
public void transform(Element element) {
((SimpleTransformer) transformer).transform(element);
}
@Override
public Column getColumn() {
return column;
}
public AppearanceModelImpl getModel() {
return model;
}
@Override
public Transformer getTransformer() {
return transformer;
}
@Override
public TransformerUI getUI() {
return transformerUI;
}
@Override
public boolean isSimple() {
return column == null;
}
@Override
public boolean isAttribute() {
return column != null;
}
@Override
public boolean isPartition() {
return partition != null;
}
@Override
public boolean isRanking() {
return false;
}
@Override
public Partition getPartition() {
return partition;
}
@Override
public String toString() {
if (column != null) {
if (column.getTitle() != null) {
return column.getTitle();
} else {
return column.getId();
}
}
return super.toString();
}
}
@@ -0,0 +1,107 @@
/*
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.appearance;
import java.awt.Color;
import java.util.HashMap;
import java.util.Map;
import org.gephi.appearance.api.Partition;
import org.gephi.attribute.api.Column;
import org.gephi.attribute.api.Index;
/**
*
* @author mbastian
*/
public class PartitionImpl implements Partition {
private final Index index;
private final Column column;
private final Map<Object, Color> colorMap;
public PartitionImpl(Column column, Index index) {
this.column = column;
this.index = index;
this.colorMap = new HashMap<Object, Color>();
}
@Override
public Iterable getValues() {
return index.values(column);
}
@Override
public int getElementCount() {
return index.countElements(column);
}
@Override
public int count(Object value) {
return index.count(column, value);
}
@Override
public Color getColor(Object value) {
return colorMap.get(value);
}
@Override
public void setColor(Object value, Color color) {
colorMap.put(value, color);
}
@Override
public float percentage(Object value) {
int count = index.count(column, value);
return (float) count / index.countElements(column);
}
@Override
public int size() {
return index.countValues(column);
}
@Override
public Column getColumn() {
return column;
}
}
@@ -1,6 +1,43 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.appearance.api;
@@ -1,6 +1,43 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.appearance.api;
@@ -37,5 +74,9 @@ public interface AppearanceModel {
* @return <code>true</code> if using a local scale, <code>false</code> if
* global scale
*/
public boolean useLocalScale();
public boolean isLocalScale();
public Function[] getNodeFunctions();
public Function[] getEdgeFunctions();
}
@@ -0,0 +1,53 @@
/*
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.appearance.api;
import org.gephi.attribute.api.Column;
/**
*
* @author mbastian
*/
public interface AttributeFunction extends Function {
public Column getColumn();
}
@@ -0,0 +1,64 @@
/*
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.appearance.api;
import org.gephi.appearance.spi.Transformer;
import org.gephi.appearance.spi.TransformerUI;
/**
*
* @author mbastian
*/
public interface Function {
public Transformer getTransformer();
public TransformerUI getUI();
public boolean isSimple();
public boolean isAttribute();
public boolean isRanking();
public boolean isPartition();
}
@@ -1,18 +0,0 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.gephi.appearance.api;
import java.awt.Color;
/**
*
* @author mbastian
*/
public interface Part {
public Color getColor();
public void setColor();
}
@@ -1,12 +1,68 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.appearance.api;
import java.awt.Color;
import org.gephi.attribute.api.Column;
/**
*
* @author mbastian
*/
public interface Partition {
public Iterable getValues();
public int getElementCount();
public int count(Object value);
public Color getColor(Object value);
public void setColor(Object value, Color color);
public float percentage(Object value);
public int size();
public Column getColumn();
}
@@ -0,0 +1,51 @@
/*
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.appearance.api;
/**
*
* @author mbastian
*/
public interface PartitionFunction extends AttributeFunction {
public Partition getPartition();
}
@@ -0,0 +1,49 @@
/*
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.appearance.api;
/**
*
* @author mbastian
*/
public interface RankingFunction extends AttributeFunction {
}
@@ -0,0 +1,53 @@
/*
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.appearance.api;
import org.gephi.graph.api.Element;
/**
*
* @author mbastian
*/
public interface SimpleFunction extends Function {
public void transform(Element element);
}
@@ -1,22 +0,0 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.gephi.appearance.spi;
import javax.swing.Icon;
/**
*
* @author mbastian
*/
public interface Category {
public String getName();
public Icon getIcon();
public boolean isNode();
public boolean isEdge();
}
@@ -1,10 +1,47 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.appearance.spi;
import org.gephi.appearance.api.Part;
import org.gephi.appearance.api.Partition;
import org.gephi.graph.api.Element;
/**
@@ -13,5 +50,5 @@ import org.gephi.graph.api.Element;
*/
public interface PartitionTransformer<E extends Element> extends Transformer {
public void transform(E element, Part part);
public void transform(E element, Partition partition, Object value);
}
@@ -1,17 +0,0 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.gephi.appearance.spi;
import javax.swing.JPanel;
import org.gephi.appearance.api.Partition;
/**
*
* @author mbastian
*/
public interface PartitionTransformerUI extends TransformerUI<PartitionTransformer> {
public JPanel getPanel(PartitionTransformer transformer, Partition partition);
}
@@ -1,6 +1,43 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.appearance.spi;
@@ -1,16 +0,0 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.gephi.appearance.spi;
import javax.swing.JPanel;
/**
*
* @author mbastian
*/
public interface RankingTransformerUI extends TransformerUI<RankingTransformer> {
public JPanel getPanel(RankingTransformer transformer, Number min, Number max);
}
@@ -1,6 +1,43 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.appearance.spi;
@@ -1,16 +0,0 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.gephi.appearance.spi;
import javax.swing.JPanel;
/**
*
* @author mbastian
*/
public interface SimpleTransformerUI extends TransformerUI<SimpleTransformer> {
public JPanel getPanel(SimpleTransformer transformer);
}
@@ -1,6 +1,43 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.appearance.spi;
@@ -9,4 +46,8 @@ package org.gephi.appearance.spi;
* @author mbastian
*/
public interface Transformer {
public boolean isNode();
public boolean isEdge();
}
@@ -0,0 +1,55 @@
/*
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.appearance.spi;
import javax.swing.Icon;
/**
*
* @author mbastian
*/
public interface TransformerCategory {
public String getDisplayName();
public Icon getIcon();
}
@@ -1,10 +1,49 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.appearance.spi;
import javax.swing.Icon;
import javax.swing.JPanel;
import org.gephi.appearance.api.Function;
/**
*
@@ -12,7 +51,9 @@ import javax.swing.Icon;
*/
public interface TransformerUI<T extends Transformer> {
public Category[] getCategories();
public TransformerCategory getCategory();
public JPanel getPanel(Function function);
public String getDisplayName();
@@ -1,12 +1,50 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.appearance.plugin;
import java.awt.Color;
import org.gephi.appearance.api.Part;
import org.gephi.appearance.api.Partition;
import org.gephi.appearance.spi.PartitionTransformer;
import org.gephi.appearance.spi.Transformer;
import org.gephi.graph.api.Element;
import org.openide.util.lookup.ServiceProvider;
@@ -14,12 +52,22 @@ import org.openide.util.lookup.ServiceProvider;
*
* @author mbastian
*/
@ServiceProvider(service = PartitionTransformer.class)
@ServiceProvider(service = Transformer.class)
public class PartitionElementColorTransformer implements PartitionTransformer<Element> {
@Override
public void transform(Element element, Part part) {
Color color = part.getColor();
public void transform(Element element, Partition partition, Object value) {
Color color = partition.getColor(value);
element.setColor(color);
}
@Override
public boolean isNode() {
return true;
}
@Override
public boolean isEdge() {
return true;
}
}
@@ -1,6 +1,43 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.appearance.plugin;
@@ -8,6 +45,7 @@ import java.awt.Color;
import java.io.Serializable;
import java.util.Arrays;
import org.gephi.appearance.spi.RankingTransformer;
import org.gephi.appearance.spi.Transformer;
import org.gephi.graph.api.Element;
import org.openide.util.lookup.ServiceProvider;
@@ -15,7 +53,7 @@ import org.openide.util.lookup.ServiceProvider;
*
* @author mbastian
*/
@ServiceProvider(service = RankingTransformer.class)
@ServiceProvider(service = Transformer.class)
public class RankingElementColorTransformer implements RankingTransformer<Element> {
protected final LinearGradient linearGradient = new LinearGradient(new Color[]{Color.WHITE, Color.BLACK}, new float[]{0f, 1f});
@@ -26,6 +64,16 @@ public class RankingElementColorTransformer implements RankingTransformer<Elemen
element.setColor(color);
}
@Override
public boolean isNode() {
return true;
}
@Override
public boolean isEdge() {
return true;
}
public float[] getColorPositions() {
return linearGradient.getPositions();
}
@@ -1,11 +1,48 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.appearance.plugin;
import java.awt.Color;
import org.gephi.appearance.spi.RankingTransformer;
import org.gephi.appearance.spi.Transformer;
import org.gephi.graph.api.Element;
import org.openide.util.lookup.ServiceProvider;
@@ -13,7 +50,7 @@ import org.openide.util.lookup.ServiceProvider;
*
* @author mbastian
*/
@ServiceProvider(service = RankingTransformer.class)
@ServiceProvider(service = Transformer.class)
public class RankingLabelColorTransformer extends RankingElementColorTransformer {
@Override
@@ -21,4 +58,14 @@ public class RankingLabelColorTransformer extends RankingElementColorTransformer
Color color = linearGradient.getValue(rankingValue);
element.getTextProperties().setColor(color);
}
@Override
public boolean isNode() {
return true;
}
@Override
public boolean isEdge() {
return true;
}
}
@@ -1,10 +1,48 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.appearance.plugin;
import org.gephi.appearance.spi.RankingTransformer;
import org.gephi.appearance.spi.Transformer;
import org.gephi.graph.api.Node;
import org.openide.util.lookup.ServiceProvider;
@@ -12,7 +50,7 @@ import org.openide.util.lookup.ServiceProvider;
*
* @author mbastian
*/
@ServiceProvider(service = RankingTransformer.class)
@ServiceProvider(service = Transformer.class)
public class RankingNodeSizeTransformer implements RankingTransformer<Node> {
protected float minSize = 1f;
@@ -24,6 +62,16 @@ public class RankingNodeSizeTransformer implements RankingTransformer<Node> {
node.setSize(size);
}
@Override
public boolean isNode() {
return true;
}
@Override
public boolean isEdge() {
return false;
}
public float getMaxSize() {
return maxSize;
}
@@ -1,11 +1,49 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.appearance.plugin;
import java.awt.Color;
import org.gephi.appearance.spi.SimpleTransformer;
import org.gephi.appearance.spi.Transformer;
import org.gephi.graph.api.Element;
import org.openide.util.lookup.ServiceProvider;
@@ -13,16 +51,26 @@ import org.openide.util.lookup.ServiceProvider;
*
* @author mbastian
*/
@ServiceProvider(service = SimpleTransformer.class)
@ServiceProvider(service = Transformer.class)
public class UniqueElementColorTransformer implements SimpleTransformer<Element> {
private Color color;
private Color color = Color.BLACK;
@Override
public void transform(Element element) {
element.setColor(color);
}
@Override
public boolean isNode() {
return true;
}
@Override
public boolean isEdge() {
return true;
}
public Color getColor() {
return color;
}
@@ -1,10 +1,48 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.appearance.plugin;
import org.gephi.appearance.spi.SimpleTransformer;
import org.gephi.appearance.spi.Transformer;
import org.gephi.graph.api.Node;
import org.openide.util.lookup.ServiceProvider;
@@ -12,7 +50,7 @@ import org.openide.util.lookup.ServiceProvider;
*
* @author mbastian
*/
@ServiceProvider(service = SimpleTransformer.class)
@ServiceProvider(service = Transformer.class)
public class UniqueNodeSizeTransformer implements SimpleTransformer<Node> {
private float size = 10f;
@@ -22,6 +60,16 @@ public class UniqueNodeSizeTransformer implements SimpleTransformer<Node> {
node.setSize(size);
}
@Override
public boolean isNode() {
return true;
}
@Override
public boolean isEdge() {
return false;
}
public float getSize() {
return size;
}
@@ -41,6 +41,7 @@
*/
package org.gephi.ui.appearance.plugin;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.event.MouseAdapter;
@@ -48,6 +49,10 @@ import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import javax.swing.AbstractCellEditor;
import javax.swing.Icon;
import javax.swing.JLabel;
@@ -58,10 +63,8 @@ import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import net.java.dev.colorchooser.ColorChooser;
import org.gephi.appearance.api.Part;
import org.gephi.appearance.api.Partition;
import org.gephi.appearance.api.PartitionFunction;
import org.gephi.appearance.plugin.PartitionElementColorTransformer;
import org.gephi.appearance.spi.PartitionTransformer;
/**
*
@@ -70,7 +73,7 @@ import org.gephi.appearance.spi.PartitionTransformer;
public class PartitionColorTransformerPanel extends javax.swing.JPanel {
private PartitionElementColorTransformer nodeColorTransformer;
private Partition partition;
private PartitionFunction function;
private JPopupMenu popupMenu;
public PartitionColorTransformerPanel() {
@@ -100,8 +103,8 @@ public class PartitionColorTransformerPanel extends javax.swing.JPanel {
table.setRowHeight(18);
}
public void setup(PartitionTransformer transformer, Partition partition) {
nodeColorTransformer = (PartitionElementColorTransformer) transformer;
public void setup(PartitionFunction function) {
this.function = function;
// if (color) {
// List<Color> colors = PaletteUtils.getSequenceColors(partition.getPartsCount());
// int i = 0;
@@ -112,15 +115,23 @@ public class PartitionColorTransformerPanel extends javax.swing.JPanel {
// }
NumberFormat formatter = NumberFormat.getPercentInstance();
formatter.setMaximumFractionDigits(2);
this.partition = partition;
// Part[] partsArray = partition.getParts();
Part[] partsArray = null;
// Arrays.sort(partsArray);
List values = new ArrayList();
for (Object value : function.getPartition().getValues()) {
values.add(value);
}
Collections.sort(values, new Comparator() {
@Override
public int compare(Object o1, Object o2) {
float p1 = PartitionColorTransformerPanel.this.function.getPartition().percentage(o1);
float p2 = PartitionColorTransformerPanel.this.function.getPartition().percentage(o2);
return p1 > p2 ? 1 : p1 < p2 ? -1 : 0;
}
});
//Model
String[] columnNames = new String[]{"Color", "Partition", "Percentage"};
DefaultTableModel model = new DefaultTableModel(columnNames, partsArray.length) {
DefaultTableModel model = new DefaultTableModel(columnNames, values.size()) {
@Override
public boolean isCellEditable(int row, int column) {
return column == 0;
@@ -142,13 +153,15 @@ public class PartitionColorTransformerPanel extends javax.swing.JPanel {
colorCol.setPreferredWidth(16);
colorCol.setMaxWidth(16);
// for (int j = 0; j < partsArray.length; j++) {
// final Part p = partsArray[partsArray.length - 1 - j];
// model.setValueAt(p.getValue(), j, 0);
// model.setValueAt(p.getDisplayName(), j, 1);
// String perc = "(" + formatter.format(p.getPercentage()) + ")";
// model.setValueAt(perc, j, 2);
// }
for (int j = 0; j < values.size(); j++) {
Object value = values.get(j);
String displayName = value == null ? "null" : value.toString();
float percentage = function.getPartition().percentage(value);
model.setValueAt(value, j, 0);
model.setValueAt(displayName, j, 1);
String perc = "(" + formatter.format(percentage) + ")";
model.setValueAt(perc, j, 2);
}
}
private void createPopup() {
@@ -184,9 +197,11 @@ public class PartitionColorTransformerPanel extends javax.swing.JPanel {
setOpaque(true);
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
// Color c = nodeColorTransformer.getMap().get(value);
// setBackground(c);
Color c = function.getPartition().getColor(value);
setBackground(c);
return this;
}
}
@@ -200,6 +215,7 @@ public class PartitionColorTransformerPanel extends javax.swing.JPanel {
emptyIcon = new EmptyIcon();
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
setText((String) value);
if (column == 1) {
@@ -213,13 +229,16 @@ public class PartitionColorTransformerPanel extends javax.swing.JPanel {
class EmptyIcon implements Icon {
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
}
@Override
public int getIconWidth() {
return 6;
}
@Override
public int getIconHeight() {
return 6;
}
@@ -236,16 +255,18 @@ public class PartitionColorTransformerPanel extends javax.swing.JPanel {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals(ColorChooser.PROP_COLOR)) {
// nodeColorTransformer.getMap().put(currentValue, (Color) evt.getNewValue());
function.getPartition().setColor(currentValue, (Color) evt.getNewValue());
}
}
});
}
@Override
public Object getCellEditorValue() {
return currentValue;
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected,
int row, int column) {
currentValue = value;
@@ -1,16 +1,53 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.ui.appearance.plugin;
import javax.swing.Icon;
import javax.swing.JPanel;
import org.gephi.appearance.api.Partition;
import org.gephi.appearance.api.Function;
import org.gephi.appearance.api.PartitionFunction;
import org.gephi.appearance.plugin.PartitionElementColorTransformer;
import org.gephi.appearance.spi.Category;
import org.gephi.appearance.spi.PartitionTransformer;
import org.gephi.appearance.spi.PartitionTransformerUI;
import org.gephi.appearance.spi.TransformerCategory;
import org.gephi.appearance.spi.TransformerUI;
import org.gephi.ui.appearance.plugin.category.DefaultCategory;
import org.openide.util.NbBundle;
@@ -21,17 +58,13 @@ import org.openide.util.lookup.ServiceProvider;
* @author mbastian
*/
@ServiceProvider(service = TransformerUI.class, position = 200)
public class PartitionElementColorTransformerUI implements PartitionTransformerUI {
public class PartitionElementColorTransformerUI implements TransformerUI {
private final PartitionColorTransformerPanel panel;
public PartitionElementColorTransformerUI() {
panel = new PartitionColorTransformerPanel();
}
private PartitionColorTransformerPanel panel;
@Override
public Category[] getCategories() {
return new Category[]{DefaultCategory.NODE_COLOR, DefaultCategory.EDGE_COLOR};
public TransformerCategory getCategory() {
return DefaultCategory.COLOR;
}
@Override
@@ -50,8 +83,11 @@ public class PartitionElementColorTransformerUI implements PartitionTransformerU
}
@Override
public JPanel getPanel(PartitionTransformer transformer, Partition partition) {
panel.setup(transformer, partition);
public synchronized JPanel getPanel(Function function) {
if (panel == null) {
panel = new PartitionColorTransformerPanel();
}
panel.setup((PartitionFunction) function);
return panel;
}
@@ -23,26 +23,9 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="labelColor" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="gradientPanel" min="-2" pref="160" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="labelRange" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="10" pref="10" max="10" attributes="0"/>
<Component id="lowerBoundLabel" min="-2" pref="75" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="upperBoundLabel" min="-2" pref="46" max="-2" attributes="0"/>
</Group>
<Component id="rangeSlider" alignment="0" min="-2" pref="162" max="-2" attributes="1"/>
</Group>
</Group>
</Group>
<Component id="labelColor" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="gradientPanel" min="-2" pref="160" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="colorSwatchToolbar" min="-2" max="-2" attributes="0"/>
</Group>
@@ -59,19 +42,9 @@
<Component id="labelColor" min="-2" pref="20" max="-2" attributes="1"/>
<Component id="gradientPanel" min="-2" pref="17" max="-2" attributes="1"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="rangeSlider" min="-2" max="-2" attributes="1"/>
<Component id="labelRange" alignment="0" min="-2" pref="23" max="-2" attributes="1"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="lowerBoundLabel" alignment="3" min="-2" max="-2" attributes="1"/>
<Component id="upperBoundLabel" alignment="3" min="-2" max="-2" attributes="1"/>
</Group>
</Group>
</Group>
<EmptySpace pref="22" max="32767" attributes="0"/>
<EmptySpace pref="88" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -91,51 +64,6 @@
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
</Container>
<Component class="javax.swing.JSlider" name="rangeSlider">
<Properties>
<Property name="focusable" type="boolean" value="false"/>
<Property name="opaque" type="boolean" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="false" type="code"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new JRangeSlider()"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="labelRange">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/gephi/ui/appearance/plugin/Bundle.properties" key="RankingColorTransformerPanel.labelRange.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="upperBoundLabel">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="10" style="0"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="66" green="66" red="66" type="rgb"/>
</Property>
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/gephi/ui/appearance/plugin/Bundle.properties" key="RankingColorTransformerPanel.upperBoundLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lowerBoundLabel">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="10" style="0"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="66" green="66" red="66" type="rgb"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/gephi/ui/appearance/plugin/Bundle.properties" key="RankingColorTransformerPanel.lowerBoundLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Container class="javax.swing.JToolBar" name="colorSwatchToolbar">
<Properties>
<Property name="floatable" type="boolean" value="false"/>
@@ -57,9 +57,8 @@ import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.gephi.appearance.api.RankingFunction;
import org.gephi.appearance.plugin.RankingElementColorTransformer;
import org.gephi.appearance.spi.RankingTransformer;
import org.gephi.ui.components.JRangeSlider;
import org.gephi.ui.components.PaletteIcon;
import org.gephi.ui.components.gradientslider.GradientSlider;
import org.gephi.utils.PaletteUtils;
@@ -72,7 +71,6 @@ import org.openide.util.NbPreferences;
*/
public class RankingColorTransformerPanel extends javax.swing.JPanel {
private static final int SLIDER_MAXIMUM = 100;
private RankingElementColorTransformer colorTransformer;
private GradientSlider gradientSlider;
private final RecentPalettes recentPalettes;
@@ -82,12 +80,11 @@ public class RankingColorTransformerPanel extends javax.swing.JPanel {
this.recentPalettes = new RecentPalettes();
}
public void setup(RankingTransformer transformer) {
public void setup(RankingFunction function) {
colorTransformer = (RankingElementColorTransformer) function.getTransformer();
final String POSITIONS = "ColorTransformerPanel_" + transformer.getClass().getSimpleName() + "_positions";
final String COLORS = "ColorTransformerPanel_" + transformer.getClass().getSimpleName() + "_colors";
colorTransformer = (RankingElementColorTransformer) transformer;
final String POSITIONS = "RankingColorTransformerPanel_" + colorTransformer.getClass().getSimpleName() + "_positions";
final String COLORS = "RankingColorTransformerPanel_" + colorTransformer.getClass().getSimpleName() + "_colors";
float[] positionsStart = colorTransformer.getColorPositions();
Color[] colorsStart = colorTransformer.getColors();
@@ -104,6 +101,7 @@ public class RankingColorTransformerPanel extends javax.swing.JPanel {
gradientSlider = new GradientSlider(GradientSlider.HORIZONTAL, positionsStart, colorsStart);
gradientSlider.putClientProperty("GradientSlider.includeOpacity", "false");
gradientSlider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
Color[] colors = gradientSlider.getColors();
float[] positions = gradientSlider.getThumbPositions();
@@ -125,6 +123,7 @@ public class RankingColorTransformerPanel extends javax.swing.JPanel {
//Context
// setComponentPopupMenu(getPalettePopupMenu());
addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent evt) {
if (evt.isPopupTrigger()) {
JPopupMenu popupMenu = getPalettePopupMenu();
@@ -132,6 +131,7 @@ public class RankingColorTransformerPanel extends javax.swing.JPanel {
}
}
@Override
public void mouseReleased(MouseEvent evt) {
if (evt.isPopupTrigger()) {
JPopupMenu popupMenu = getPalettePopupMenu();
@@ -142,6 +142,7 @@ public class RankingColorTransformerPanel extends javax.swing.JPanel {
//Color Swatch
colorSwatchButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
JPopupMenu popupMenu = getPalettePopupMenu();
popupMenu.show(colorSwatchToolbar, -popupMenu.getPreferredSize().width, 0);
@@ -169,6 +170,7 @@ public class RankingColorTransformerPanel extends javax.swing.JPanel {
final Palette p3 = PaletteUtils.get3ClassPalette(p);
JMenuItem item = new JMenuItem(new PaletteIcon(p3.getColors()));
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gradientSlider.setValues(p3.getPositions(), p3.getColors());
}
@@ -179,6 +181,7 @@ public class RankingColorTransformerPanel extends javax.swing.JPanel {
final Palette p3 = PaletteUtils.get3ClassPalette(p);
JMenuItem item = new JMenuItem(new PaletteIcon(p3.getColors()));
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gradientSlider.setValues(p3.getPositions(), p3.getColors());
}
@@ -190,6 +193,7 @@ public class RankingColorTransformerPanel extends javax.swing.JPanel {
//Invert
JMenuItem invertItem = new JMenuItem(NbBundle.getMessage(RankingColorTransformerPanel.class, "PalettePopup.invert"));
invertItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gradientSlider.setValues(invert(gradientSlider.getThumbPositions()), invert(gradientSlider.getColors()));
}
@@ -201,6 +205,7 @@ public class RankingColorTransformerPanel extends javax.swing.JPanel {
for (final RankingElementColorTransformer.LinearGradient gradient : recentPalettes.getPalettes()) {
JMenuItem item = new JMenuItem(new PaletteIcon(gradient.getColors()));
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gradientSlider.setValues(gradient.getPositions(), gradient.getColors());
}
@@ -279,10 +284,6 @@ public class RankingColorTransformerPanel extends javax.swing.JPanel {
labelColor = new javax.swing.JLabel();
gradientPanel = new javax.swing.JPanel();
rangeSlider = new JRangeSlider();
labelRange = new javax.swing.JLabel();
upperBoundLabel = new javax.swing.JLabel();
lowerBoundLabel = new javax.swing.JLabel();
colorSwatchToolbar = new javax.swing.JToolBar();
colorSwatchButton = new javax.swing.JButton();
@@ -293,20 +294,6 @@ public class RankingColorTransformerPanel extends javax.swing.JPanel {
gradientPanel.setOpaque(false);
gradientPanel.setLayout(new java.awt.BorderLayout());
rangeSlider.setFocusable(false);
rangeSlider.setOpaque(false);
labelRange.setText(org.openide.util.NbBundle.getMessage(RankingColorTransformerPanel.class, "RankingColorTransformerPanel.labelRange.text")); // NOI18N
upperBoundLabel.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
upperBoundLabel.setForeground(new java.awt.Color(102, 102, 102));
upperBoundLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
upperBoundLabel.setText(org.openide.util.NbBundle.getMessage(RankingColorTransformerPanel.class, "RankingColorTransformerPanel.upperBoundLabel.text")); // NOI18N
lowerBoundLabel.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
lowerBoundLabel.setForeground(new java.awt.Color(102, 102, 102));
lowerBoundLabel.setText(org.openide.util.NbBundle.getMessage(RankingColorTransformerPanel.class, "RankingColorTransformerPanel.lowerBoundLabel.text")); // NOI18N
colorSwatchToolbar.setFloatable(false);
colorSwatchToolbar.setRollover(true);
colorSwatchToolbar.setOpaque(false);
@@ -325,21 +312,9 @@ public class RankingColorTransformerPanel extends javax.swing.JPanel {
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(labelColor)
.addGap(18, 18, 18)
.addComponent(gradientPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(labelRange)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(lowerBoundLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(upperBoundLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(rangeSlider, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addComponent(labelColor)
.addGap(18, 18, 18)
.addComponent(gradientPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(colorSwatchToolbar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
@@ -352,16 +327,8 @@ public class RankingColorTransformerPanel extends javax.swing.JPanel {
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(labelColor, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(gradientPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(rangeSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(labelRange, 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(lowerBoundLabel)
.addComponent(upperBoundLabel))))
.addContainerGap(22, Short.MAX_VALUE))
.addComponent(gradientPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(88, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
@@ -369,9 +336,5 @@ public class RankingColorTransformerPanel extends javax.swing.JPanel {
private javax.swing.JToolBar colorSwatchToolbar;
private javax.swing.JPanel gradientPanel;
private javax.swing.JLabel labelColor;
private javax.swing.JLabel labelRange;
private javax.swing.JLabel lowerBoundLabel;
private javax.swing.JSlider rangeSlider;
private javax.swing.JLabel upperBoundLabel;
// End of variables declaration//GEN-END:variables
}
@@ -1,15 +1,53 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.ui.appearance.plugin;
import javax.swing.Icon;
import javax.swing.JPanel;
import org.gephi.appearance.api.Function;
import org.gephi.appearance.api.RankingFunction;
import org.gephi.appearance.plugin.RankingElementColorTransformer;
import org.gephi.appearance.spi.Category;
import org.gephi.appearance.spi.RankingTransformer;
import org.gephi.appearance.spi.RankingTransformerUI;
import org.gephi.appearance.spi.TransformerCategory;
import org.gephi.appearance.spi.TransformerUI;
import org.gephi.ui.appearance.plugin.category.DefaultCategory;
import org.openide.util.NbBundle;
@@ -20,17 +58,13 @@ import org.openide.util.lookup.ServiceProvider;
* @author mbastian
*/
@ServiceProvider(service = TransformerUI.class, position = 200)
public class RankingElementColorTransformerUI implements RankingTransformerUI {
public class RankingElementColorTransformerUI implements TransformerUI {
private final RankingColorTransformerPanel panel;
public RankingElementColorTransformerUI() {
panel = new RankingColorTransformerPanel();
}
private RankingColorTransformerPanel panel;
@Override
public Category[] getCategories() {
return new Category[]{DefaultCategory.NODE_COLOR, DefaultCategory.EDGE_COLOR};
public TransformerCategory getCategory() {
return DefaultCategory.COLOR;
}
@Override
@@ -49,8 +83,11 @@ public class RankingElementColorTransformerUI implements RankingTransformerUI {
}
@Override
public JPanel getPanel(RankingTransformer transformer, Number min, Number max) {
panel.setup(transformer);
public synchronized JPanel getPanel(Function function) {
if (panel == null) {
panel = new RankingColorTransformerPanel();
}
panel.setup((RankingFunction) function);
return panel;
}
@@ -0,0 +1,98 @@
/*
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.ui.appearance.plugin;
import javax.swing.Icon;
import javax.swing.JPanel;
import org.gephi.appearance.api.Function;
import org.gephi.appearance.api.RankingFunction;
import org.gephi.appearance.plugin.RankingNodeSizeTransformer;
import org.gephi.appearance.spi.RankingTransformer;
import org.gephi.appearance.spi.TransformerCategory;
import org.gephi.appearance.spi.TransformerUI;
import org.gephi.ui.appearance.plugin.category.DefaultCategory;
import org.openide.util.NbBundle;
import org.openide.util.lookup.ServiceProvider;
/**
*
* @author mbastian
*/
@ServiceProvider(service = TransformerUI.class, position = 300)
public class RankingElementSizeTransformerUI implements TransformerUI {
private RankingSizeTransformerPanel panel;
@Override
public TransformerCategory getCategory() {
return DefaultCategory.SIZE;
}
@Override
public Icon getIcon() {
return null;
}
@Override
public String getDisplayName() {
return NbBundle.getMessage(UniqueElementColorTransformerUI.class, "Attribute.name");
}
@Override
public String getDescription() {
return null;
}
@Override
public synchronized JPanel getPanel(Function function) {
if (panel == null) {
panel = new RankingSizeTransformerPanel();
}
panel.setup((RankingFunction) function);
return panel;
}
@Override
public Class<? extends RankingTransformer> getTransformerClass() {
return RankingNodeSizeTransformer.class;
}
}
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Properties>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[225, 114]"/>
</Property>
</Properties>
<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" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="labelMinSize" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="8" max="-2" attributes="0"/>
<Component id="minSize" min="-2" pref="55" max="-2" attributes="1"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="labelMaxSize" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="maxSize" min="-2" pref="55" max="-2" attributes="1"/>
<EmptySpace max="32767" 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"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="minSize" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="maxSize" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="labelMaxSize" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="labelMinSize" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="80" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="labelMinSize">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/gephi/ui/appearance/plugin/Bundle.properties" key="RankingSizeTransformerPanel.labelMinSize.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="minSize">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="1.0" minimum="0.1" numberType="java.lang.Float" stepSize="0.5" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="labelMaxSize">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/gephi/ui/appearance/plugin/Bundle.properties" key="RankingSizeTransformerPanel.labelMaxSize.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="maxSize">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="4.0" minimum="0.5" numberType="java.lang.Float" stepSize="0.5" type="number"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Form>
@@ -0,0 +1,148 @@
/*
Copyright 2008-2010 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
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.ui.appearance.plugin;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.gephi.appearance.api.RankingFunction;
import org.gephi.appearance.plugin.RankingNodeSizeTransformer;
import org.openide.util.NbPreferences;
/**
*
* @author Mathieu Bastian
*/
public class RankingSizeTransformerPanel extends javax.swing.JPanel {
private RankingNodeSizeTransformer sizeTransformer;
public RankingSizeTransformerPanel() {
initComponents();
}
public void setup(RankingFunction function) {
sizeTransformer = (RankingNodeSizeTransformer) function.getTransformer();
final String MIN_SIZE = "RankingSizeTransformerPanel_" + sizeTransformer.getClass().getSimpleName() + "_min";
final String MAX_SIZE = "RankingSizeTransformerPanel_" + sizeTransformer.getClass().getSimpleName() + "_max";
float minSizeStart = NbPreferences.forModule(RankingSizeTransformerPanel.class).getFloat(MIN_SIZE, sizeTransformer.getMinSize());
float maxSizeStart = NbPreferences.forModule(RankingSizeTransformerPanel.class).getFloat(MAX_SIZE, sizeTransformer.getMaxSize());
sizeTransformer.setMinSize(minSizeStart);
sizeTransformer.setMaxSize(maxSizeStart);
minSize.setValue(minSizeStart);
maxSize.setValue(maxSizeStart);
minSize.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
sizeTransformer.setMinSize((Float) minSize.getValue());
NbPreferences.forModule(RankingSizeTransformerPanel.class).putFloat(MIN_SIZE, (Float) minSize.getValue());
}
});
maxSize.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
sizeTransformer.setMaxSize((Float) maxSize.getValue());
NbPreferences.forModule(RankingSizeTransformerPanel.class).putFloat(MAX_SIZE, (Float) maxSize.getValue());
}
});
}
/**
* 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() {
labelMinSize = new javax.swing.JLabel();
minSize = new javax.swing.JSpinner();
labelMaxSize = new javax.swing.JLabel();
maxSize = new javax.swing.JSpinner();
setPreferredSize(new java.awt.Dimension(225, 114));
labelMinSize.setText(org.openide.util.NbBundle.getMessage(RankingSizeTransformerPanel.class, "RankingSizeTransformerPanel.labelMinSize.text")); // NOI18N
minSize.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(1.0f), Float.valueOf(0.1f), null, Float.valueOf(0.5f)));
labelMaxSize.setText(org.openide.util.NbBundle.getMessage(RankingSizeTransformerPanel.class, "RankingSizeTransformerPanel.labelMaxSize.text")); // NOI18N
maxSize.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(4.0f), Float.valueOf(0.5f), null, Float.valueOf(0.5f)));
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()
.addComponent(labelMinSize)
.addGap(8, 8, 8)
.addComponent(minSize, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(labelMaxSize)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(maxSize, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(minSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(maxSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(labelMaxSize)
.addComponent(labelMinSize))
.addContainerGap(80, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel labelMaxSize;
private javax.swing.JLabel labelMinSize;
private javax.swing.JSpinner maxSize;
private javax.swing.JSpinner minSize;
// End of variables declaration//GEN-END:variables
}
@@ -1,15 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.4" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<NonVisualComponents>
<Component class="javax.swing.JButton" name="jButton1">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/gephi/ui/appearance/plugin/Bundle.properties" key="UniqueColorTransformerPanel.jButton1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
</NonVisualComponents>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
@@ -27,8 +18,10 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="colorButton" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="316" max="32767" attributes="0"/>
<Component id="colorChooser" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="colorLabel" min="-2" pref="380" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -36,19 +29,43 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="colorButton" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="265" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="colorLabel" min="-2" max="-2" attributes="0"/>
<Component id="colorChooser" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="278" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="colorButton">
<Container class="net.java.dev.colorchooser.ColorChooser" name="colorChooser">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/gephi/ui/appearance/plugin/Bundle.properties" key="UniqueColorTransformerPanel.colorButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[14, 14]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[14, 14]"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/gephi/ui/appearance/plugin/Bundle.properties" key="UniqueColorTransformerPanel.colorChooser.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="12" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="12" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Container>
<Component class="javax.swing.JLabel" name="colorLabel">
</Component>
</SubComponents>
</Form>
@@ -1,20 +1,83 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.ui.appearance.plugin;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import org.gephi.appearance.api.SimpleFunction;
import org.gephi.appearance.plugin.UniqueElementColorTransformer;
/**
*
* @author mbastian
*/
public class UniqueColorTransformerPanel extends javax.swing.JPanel {
private UniqueElementColorTransformer transformer;
/**
* Creates new form UniqueNodeColorTransformerPanel
*/
public UniqueColorTransformerPanel() {
initComponents();
colorChooser.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
transformer.setColor(colorChooser.getColor());
colorLabel.setText(getHex(colorChooser.getColor()));
}
});
}
public void setup(SimpleFunction function) {
transformer = (UniqueElementColorTransformer) function.getTransformer();
colorChooser.setColor(transformer.getColor());
colorLabel.setText(getHex(transformer.getColor()));
}
private String getHex(Color color) {
return "#" + String.format("%06x", color.getRGB() & 0x00FFFFFF);
}
/**
@@ -25,13 +88,25 @@ public class UniqueColorTransformerPanel extends javax.swing.JPanel {
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
jButton1 = new javax.swing.JButton();
colorButton = new javax.swing.JButton();
colorChooser = new net.java.dev.colorchooser.ColorChooser();
colorLabel = new javax.swing.JLabel();
jButton1.setText(org.openide.util.NbBundle.getMessage(UniqueColorTransformerPanel.class, "UniqueColorTransformerPanel.jButton1.text")); // NOI18N
colorChooser.setMinimumSize(new java.awt.Dimension(14, 14));
colorChooser.setPreferredSize(new java.awt.Dimension(14, 14));
colorChooser.setToolTipText(org.openide.util.NbBundle.getMessage(UniqueColorTransformerPanel.class, "UniqueColorTransformerPanel.colorChooser.toolTipText")); // NOI18N
colorButton.setText(org.openide.util.NbBundle.getMessage(UniqueColorTransformerPanel.class, "UniqueColorTransformerPanel.colorButton.text")); // NOI18N
javax.swing.GroupLayout colorChooserLayout = new javax.swing.GroupLayout(colorChooser);
colorChooser.setLayout(colorChooserLayout);
colorChooserLayout.setHorizontalGroup(
colorChooserLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 12, Short.MAX_VALUE)
);
colorChooserLayout.setVerticalGroup(
colorChooserLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 12, Short.MAX_VALUE)
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
@@ -39,19 +114,23 @@ public class UniqueColorTransformerPanel extends javax.swing.JPanel {
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(colorButton)
.addContainerGap(316, Short.MAX_VALUE))
.addComponent(colorChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(colorLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 380, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(colorButton)
.addContainerGap(265, Short.MAX_VALUE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(colorLabel)
.addComponent(colorChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(278, 278, 278))
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton colorButton;
private javax.swing.JButton jButton1;
private net.java.dev.colorchooser.ColorChooser colorChooser;
private javax.swing.JLabel colorLabel;
// End of variables declaration//GEN-END:variables
}
@@ -1,15 +1,54 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.ui.appearance.plugin;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import org.gephi.appearance.api.Function;
import org.gephi.appearance.api.SimpleFunction;
import org.gephi.appearance.plugin.UniqueElementColorTransformer;
import org.gephi.appearance.spi.Category;
import org.gephi.appearance.spi.SimpleTransformer;
import org.gephi.appearance.spi.SimpleTransformerUI;
import org.gephi.appearance.spi.TransformerCategory;
import org.gephi.appearance.spi.TransformerUI;
import org.gephi.ui.appearance.plugin.category.DefaultCategory;
import org.openide.util.NbBundle;
@@ -20,18 +59,20 @@ import org.openide.util.lookup.ServiceProvider;
* @author mbastian
*/
@ServiceProvider(service = TransformerUI.class, position = 100)
public class UniqueElementColorTransformerUI implements SimpleTransformerUI {
public class UniqueElementColorTransformerUI implements TransformerUI {
@Override
public Category[] getCategories() {
return new Category[]{DefaultCategory.NODE_COLOR, DefaultCategory.EDGE_COLOR};
}
private UniqueColorTransformerPanel panel;
@Override
public String getDisplayName() {
return NbBundle.getMessage(UniqueElementColorTransformerUI.class, "Unique.name");
}
@Override
public TransformerCategory getCategory() {
return DefaultCategory.COLOR;
}
@Override
public String getDescription() {
return null;
@@ -39,12 +80,16 @@ public class UniqueElementColorTransformerUI implements SimpleTransformerUI {
@Override
public Icon getIcon() {
return null;
return new ImageIcon("resources/color.png");
}
@Override
public JPanel getPanel(SimpleTransformer transformer) {
return new UniqueColorTransformerPanel();
public synchronized JPanel getPanel(Function function) {
if (panel == null) {
panel = new UniqueColorTransformerPanel();
}
panel.setup((SimpleFunction) function);
return panel;
}
@Override
@@ -1,15 +1,53 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.ui.appearance.plugin;
import javax.swing.Icon;
import javax.swing.JPanel;
import org.gephi.appearance.api.Function;
import org.gephi.appearance.api.SimpleFunction;
import org.gephi.appearance.plugin.UniqueNodeSizeTransformer;
import org.gephi.appearance.spi.Category;
import org.gephi.appearance.spi.SimpleTransformer;
import org.gephi.appearance.spi.SimpleTransformerUI;
import org.gephi.appearance.spi.TransformerCategory;
import org.gephi.appearance.spi.TransformerUI;
import org.gephi.ui.appearance.plugin.category.DefaultCategory;
import org.openide.util.NbBundle;
@@ -20,18 +58,20 @@ import org.openide.util.lookup.ServiceProvider;
* @author mbastian
*/
@ServiceProvider(service = TransformerUI.class, position = 100)
public class UniqueNodeSizeTransformerUI implements SimpleTransformerUI {
public class UniqueNodeSizeTransformerUI implements TransformerUI {
@Override
public Category[] getCategories() {
return new Category[]{DefaultCategory.NODE_SIZE};
}
private UniqueSizeTransformerPanel panel;
@Override
public String getDisplayName() {
return NbBundle.getMessage(UniqueElementColorTransformerUI.class, "Unique.name");
}
@Override
public TransformerCategory getCategory() {
return DefaultCategory.SIZE;
}
@Override
public String getDescription() {
return null;
@@ -43,8 +83,12 @@ public class UniqueNodeSizeTransformerUI implements SimpleTransformerUI {
}
@Override
public JPanel getPanel(SimpleTransformer transformer) {
return new UniqueSizeTransformerPanel();
public synchronized JPanel getPanel(Function function) {
if (panel == null) {
panel = new UniqueSizeTransformerPanel();
}
panel.setup((SimpleFunction) function);
return panel;
}
@Override
@@ -18,8 +18,10 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="sizeButton" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="319" max="32767" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="sizeSpinner" min="-2" max="-2" attributes="1"/>
<EmptySpace pref="294" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -27,17 +29,27 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="sizeButton" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="265" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="sizeSpinner" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="266" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="sizeButton">
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/gephi/ui/appearance/plugin/Bundle.properties" key="UniqueSizeTransformerPanel.sizeButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString bundle="org/gephi/ui/appearance/plugin/Bundle.properties" key="UniqueSizeTransformerPanel.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="sizeSpinner">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="1.0" minimum="0.1" numberType="java.lang.Float" stepSize="0.5" type="number"/>
</Property>
</Properties>
</Component>
@@ -1,20 +1,73 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.ui.appearance.plugin;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.gephi.appearance.api.SimpleFunction;
import org.gephi.appearance.plugin.UniqueNodeSizeTransformer;
/**
*
* @author mbastian
*/
public class UniqueSizeTransformerPanel extends javax.swing.JPanel {
/**
* Creates new form UniqueSizeTransformerPanel
*/
private UniqueNodeSizeTransformer transformer;
public UniqueSizeTransformerPanel() {
initComponents();
sizeSpinner.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
transformer.setSize((Float) sizeSpinner.getValue());
}
});
}
public void setup(SimpleFunction function) {
transformer = (UniqueNodeSizeTransformer) function.getTransformer();
sizeSpinner.setValue(transformer.getSize());
}
/**
@@ -26,9 +79,12 @@ public class UniqueSizeTransformerPanel extends javax.swing.JPanel {
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
sizeButton = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
sizeSpinner = new javax.swing.JSpinner();
sizeButton.setText(org.openide.util.NbBundle.getMessage(UniqueSizeTransformerPanel.class, "UniqueSizeTransformerPanel.sizeButton.text")); // NOI18N
jLabel1.setText(org.openide.util.NbBundle.getMessage(UniqueSizeTransformerPanel.class, "UniqueSizeTransformerPanel.jLabel1.text")); // NOI18N
sizeSpinner.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(1.0f), Float.valueOf(0.1f), null, Float.valueOf(0.5f)));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
@@ -36,18 +92,23 @@ public class UniqueSizeTransformerPanel extends javax.swing.JPanel {
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(sizeButton)
.addContainerGap(319, Short.MAX_VALUE))
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(sizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(294, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(sizeButton)
.addContainerGap(265, Short.MAX_VALUE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(sizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(266, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton sizeButton;
private javax.swing.JLabel jLabel1;
private javax.swing.JSpinner sizeSpinner;
// End of variables declaration//GEN-END:variables
}
@@ -1,12 +1,49 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.ui.appearance.plugin.category;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import org.gephi.appearance.spi.Category;
import org.gephi.appearance.spi.TransformerCategory;
import org.openide.util.NbBundle;
/**
@@ -15,10 +52,10 @@ import org.openide.util.NbBundle;
*/
public class DefaultCategory {
public static Category NODE_SIZE = new Category() {
public static TransformerCategory SIZE = new TransformerCategory() {
@Override
public String getName() {
return NbBundle.getMessage(DefaultCategory.class, "Category.NodeSize.name");
public String getDisplayName() {
return NbBundle.getMessage(DefaultCategory.class, "Category.Size.name");
}
@Override
@@ -26,25 +63,15 @@ public class DefaultCategory {
return new ImageIcon(getClass().getResource("/org/gephi/ui/appearance/plugin/resources/size.png"));
}
@Override
public boolean isNode() {
return true;
}
@Override
public boolean isEdge() {
return false;
}
@Override
public String toString() {
return "NODE_SIZE";
return "SIZE";
}
};
public static Category NODE_COLOR = new Category() {
public static TransformerCategory COLOR = new TransformerCategory() {
@Override
public String getName() {
return NbBundle.getMessage(DefaultCategory.class, "Category.NodeColor.name");
public String getDisplayName() {
return NbBundle.getMessage(DefaultCategory.class, "Category.Color.name");
}
@Override
@@ -52,45 +79,9 @@ public class DefaultCategory {
return new ImageIcon(getClass().getResource("/org/gephi/ui/appearance/plugin/resources/color.png"));
}
@Override
public boolean isNode() {
return true;
}
@Override
public boolean isEdge() {
return false;
}
@Override
public String toString() {
return "NODE_COLOR";
}
};
public static Category EDGE_COLOR = new Category() {
@Override
public String getName() {
return NbBundle.getMessage(DefaultCategory.class, "Category.EdgeColor.name");
}
@Override
public Icon getIcon() {
return new ImageIcon(getClass().getResource("/org/gephi/ui/appearance/plugin/resources/color.png"));
}
@Override
public boolean isNode() {
return false;
}
@Override
public boolean isEdge() {
return true;
}
@Override
public String toString() {
return "EDGE_COLOR";
return "COLOR";
}
};
}
@@ -2,26 +2,18 @@
Unique.name = Unique
Attribute.name = Attribute
UniqueColorTransformerPanel.jButton1.text=jButton1
UniqueColorTransformerPanel.colorButton.text=Color
UniqueSizeTransformerPanel.sizeButton.text=Size
ColorTransformerUI.name = Color
SizeTransformerUI.name = Size/Weight
SizeTransformerUI.name = Size
LabelColorTransformerUI.name = Label Color
LabelSizeTransformerUI.name = Label Size
RankingColorTransformerPanel.labelColor.text=Color:
RankingColorTransformerPanel.labelRange.text=Range:
SizeTransformerPanel.labelMaxSize.text=Max size:
SizeTransformerPanel.labelMinSize.text=Min size:
SizeTransformerPanel.labelRange.text=Range:
SizeTransformerPanel.lowerBoundLabel.text=NaN
SizeTransformerPanel.upperBoundLabel.text=NaN
RankingColorTransformerPanel.lowerBoundLabel.text=NaN
RankingColorTransformerPanel.upperBoundLabel.text=NaN
RankingSizeTransformerPanel.labelMaxSize.text=Max size:
RankingSizeTransformerPanel.labelMinSize.text=Min size:
PalettePopup.default = Default
PalettePopup.invert = Invert
PalettePopup.recent = Recent
UniqueColorTransformerPanel.colorChooser.toolTipText=Set Color
UniqueSizeTransformerPanel.jLabel1.text=Size:
@@ -0,0 +1,2 @@
UniqueColorTransformerPanel.colorChooser.toolTipText=Hrana dovnit\u0159<- Barva
@@ -0,0 +1,2 @@
UniqueColorTransformerPanel.colorChooser.toolTipText=Color de arista Entrante <-
@@ -0,0 +1,2 @@
UniqueColorTransformerPanel.colorChooser.toolTipText=Couleur de lien ENTRANT<-
@@ -0,0 +1,2 @@
UniqueColorTransformerPanel.colorChooser.toolTipText=\u6d41\u5165\u8fba<-\u8272
@@ -0,0 +1,2 @@
UniqueColorTransformerPanel.colorChooser.toolTipText=Cor da aresta de entrada <-
@@ -0,0 +1,2 @@
UniqueColorTransformerPanel.colorChooser.toolTipText=\u0426\u0432\u0435\u0442 \u0432\u0445\u043e\u0434. \u0440\u0451\u0431\u0435\u0440
@@ -0,0 +1,2 @@
UniqueColorTransformerPanel.colorChooser.toolTipText=\u8fb9 IN<- \u989c\u8272
@@ -1,3 +1,2 @@
Category.NodeSize.name = Size
Category.NodeColor.name = Color
Category.EdgeColor.name = Color
Category.Size.name = Size
Category.Color.name = Color
@@ -3,10 +3,11 @@ AutoUpdate-Essential-Module: true
OpenIDE-Module-Localizing-Bundle: org/gephi/ui/appearance/plugin/Bundl
e.properties
OpenIDE-Module-Specification-Version: 0.8.2
OpenIDE-Module-Implementation-Version: 0.9-20130721
OpenIDE-Module-Build-Version: 201307212127
OpenIDE-Module-Implementation-Version: 0.9-20130728
OpenIDE-Module-Build-Version: 201307282250
OpenIDE-Module: org.gephi.appearance.plugin.ui
OpenIDE-Module-Public-Packages: -
OpenIDE-Module-Public-Packages: org.gephi.ui.appearance.plugin.categor
y.*
OpenIDE-Module-Requires: org.openide.modules.ModuleFormat1
OpenIDE-Module-Display-Category: org.gephi
OpenIDE-Module-Name: AppearancePluginUI
@@ -1 +0,0 @@
org.gephi.ui.appearance.plugin.RankingElementColorTransformerUI
@@ -1,4 +0,0 @@
org.gephi.ui.appearance.plugin.UniqueElementColorTransformerUI
#position=100
org.gephi.ui.appearance.plugin.UniqueNodeSizeTransformerUI
#position=200
@@ -1,26 +1,19 @@
Unique.name = Unique
Attribute.name = Attribute
UniqueColorTransformerPanel.jButton1.text=jButton1
UniqueColorTransformerPanel.colorButton.text=Color
UniqueSizeTransformerPanel.sizeButton.text=Size
ColorTransformerUI.name = Color
SizeTransformerUI.name = Size/Weight
SizeTransformerUI.name = Size
LabelColorTransformerUI.name = Label Color
LabelSizeTransformerUI.name = Label Size
RankingColorTransformerPanel.labelColor.text=Color:
RankingColorTransformerPanel.labelRange.text=Range:
SizeTransformerPanel.labelMaxSize.text=Max size:
SizeTransformerPanel.labelMinSize.text=Min size:
SizeTransformerPanel.labelRange.text=Range:
SizeTransformerPanel.lowerBoundLabel.text=NaN
SizeTransformerPanel.upperBoundLabel.text=NaN
RankingColorTransformerPanel.lowerBoundLabel.text=NaN
RankingColorTransformerPanel.upperBoundLabel.text=NaN
RankingSizeTransformerPanel.labelMaxSize.text=Max size:
RankingSizeTransformerPanel.labelMinSize.text=Min size:
PalettePopup.default = Default
PalettePopup.invert = Invert
PalettePopup.recent = Recent
UniqueColorTransformerPanel.colorChooser.toolTipText=Set Color
UniqueSizeTransformerPanel.jLabel1.text=Size:
Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 892 B

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 824 B

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 809 B

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 791 B

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 592 B

@@ -1,5 +1,5 @@
#Generated by Maven
#Sun Jul 21 14:27:15 PDT 2013
#Sat Jul 27 19:55:15 PDT 2013
version=0.9-SNAPSHOT
groupId=org.gephi
artifactId=appearance-plugin-ui
@@ -1,27 +1,34 @@
org/gephi/ui/appearance/plugin/PartitionColorTransformerPanel$4.class
org/gephi/ui/appearance/plugin/UniqueNodeSizeTransformerUI.class
org/gephi/ui/appearance/plugin/category/DefaultCategory.class
org/gephi/ui/appearance/plugin/PartitionColorTransformerPanel$2.class
org/gephi/ui/appearance/plugin/PartitionColorTransformerPanel$ColorChooserEditor$1.class
org/gephi/ui/appearance/plugin/RankingColorTransformerPanel$2.class
META-INF/services/org.gephi.appearance.spi.RankingTransformerUI
org/gephi/ui/appearance/plugin/RankingElementSizeTransformerUI.class
org/gephi/ui/appearance/plugin/RankingSizeTransformerPanel$2.class
org/gephi/ui/appearance/plugin/PartitionColorTransformerPanel$3.class
org/gephi/ui/appearance/plugin/RankingColorTransformerPanel$3.class
org/gephi/ui/appearance/plugin/PartitionColorTransformerPanel$EmptyIcon.class
org/gephi/ui/appearance/plugin/RankingColorTransformerPanel$4.class
org/gephi/ui/appearance/plugin/category/DefaultCategory$2.class
org/gephi/ui/appearance/plugin/category/DefaultCategory$1.class
org/gephi/ui/appearance/plugin/PartitionColorTransformerPanel.class
org/gephi/ui/appearance/plugin/UniqueSizeTransformerPanel$1.class
org/gephi/ui/appearance/plugin/UniqueElementColorTransformerUI.class
org/gephi/ui/appearance/plugin/UniqueSizeTransformerPanel.class
META-INF/services/org.gephi.appearance.spi.TransformerUI
org/gephi/ui/appearance/plugin/PartitionColorTransformerPanel$ColorChooserEditor$1.class
org/gephi/ui/appearance/plugin/PartitionElementColorTransformerUI.class
org/gephi/ui/appearance/plugin/PartitionColorTransformerPanel$ColorChooserRenderer.class
org/gephi/ui/appearance/plugin/PartitionColorTransformerPanel$TextRenderer.class
org/gephi/ui/appearance/plugin/PartitionColorTransformerPanel$3.class
org/gephi/ui/appearance/plugin/UniqueColorTransformerPanel.class
org/gephi/ui/appearance/plugin/RankingColorTransformerPanel$3.class
org/gephi/ui/appearance/plugin/RankingSizeTransformerPanel.class
org/gephi/ui/appearance/plugin/UniqueColorTransformerPanel$1.class
org/gephi/ui/appearance/plugin/RankingColorTransformerPanel$5.class
org/gephi/ui/appearance/plugin/PartitionColorTransformerPanel$EmptyIcon.class
org/gephi/ui/appearance/plugin/RankingColorTransformerPanel$4.class
META-INF/services/org.gephi.appearance.spi.SimpleTransformerUI
org/gephi/ui/appearance/plugin/PartitionColorTransformerPanel$1.class
org/gephi/ui/appearance/plugin/RecentPalettes.class
org/gephi/ui/appearance/plugin/RankingColorTransformerPanel$1.class
org/gephi/ui/appearance/plugin/RankingColorTransformerPanel.class
org/gephi/ui/appearance/plugin/RankingColorTransformerPanel$6.class
org/gephi/ui/appearance/plugin/PartitionColorTransformerPanel.class
org/gephi/ui/appearance/plugin/PartitionColorTransformerPanel$ColorChooserEditor.class
org/gephi/ui/appearance/plugin/RankingElementColorTransformerUI.class
org/gephi/ui/appearance/plugin/UniqueElementColorTransformerUI.class
org/gephi/ui/appearance/plugin/UniqueSizeTransformerPanel.class
org/gephi/ui/appearance/plugin/RankingSizeTransformerPanel$1.class
org/gephi/ui/appearance/plugin/RankingColorTransformerPanel$7.class
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?><module codename="org.gephi.appearance.plugin.ui">
<module_version install_time="1374442035916" last="true" origin="installer" specification_version="0.8.2">
<module_version install_time="1375051818615" last="true" origin="installer" specification_version="0.8.2">
<file crc="3192272852" name="config/Modules/org-gephi-appearance-plugin-ui.xml"/>
<file crc="589899360" name="modules/org-gephi-appearance-plugin-ui.jar"/>
<file crc="4245372469" name="modules/org-gephi-appearance-plugin-ui.jar"/>
<file crc="4054192037" name="update_tracking/org-gephi-appearance-plugin-ui.xml"/>
</module_version>
</module>
@@ -1,6 +1,43 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.desktop.appearance;
@@ -23,7 +60,8 @@ import javax.swing.JToolBar;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.border.Border;
import org.gephi.appearance.spi.Category;
import org.gephi.appearance.api.Function;
import org.gephi.appearance.spi.TransformerCategory;
import org.gephi.appearance.spi.TransformerUI;
import org.openide.util.NbBundle;
@@ -62,9 +100,9 @@ public class AppearanceToolbar implements AppearanceUIModelListener {
} else if (pce.getPropertyName().equals(AppearanceUIModelEvent.SELECTED_ELEMENT_CLASS)) {
refreshSelectedElementClass((String) pce.getNewValue());
} else if (pce.getPropertyName().equals(AppearanceUIModelEvent.SELECTED_CATEGORY)) {
refreshSelectedCategory((Category) pce.getNewValue());
} else if (pce.getPropertyName().equals(AppearanceUIModelEvent.SELECTED_TRANSFORMER_UI)) {
refreshSelectedTransformerUI((TransformerUI) pce.getNewValue());
refreshSelectedCategory((TransformerCategory) pce.getNewValue());
} else if (pce.getPropertyName().equals(AppearanceUIModelEvent.SELECTED_FUNCTION)) {
refreshSelectedFunction((Function) pce.getNewValue());
}
// if (pce.getPropertyName().equals(AppearanceUIModelEvent.CURRENT_ELEMENT_TYPE)) {
// refreshSelectedElmntGroup((String) pce.getNewValue());
@@ -109,7 +147,7 @@ public class AppearanceToolbar implements AppearanceUIModelListener {
});
}
private void refreshSelectedCategory(final Category category) {
private void refreshSelectedCategory(final TransformerCategory category) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
@@ -120,7 +158,7 @@ public class AppearanceToolbar implements AppearanceUIModelListener {
});
}
private void refreshSelectedTransformerUI(final TransformerUI ui) {
private void refreshSelectedFunction(final Function ui) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
@@ -204,21 +242,21 @@ public class AppearanceToolbar implements AppearanceUIModelListener {
//Add transformers buttons, separate them by element group
for (String elmtType : AppearanceUIController.ELEMENT_CLASSES) {
ButtonGroup buttonGroup = new ButtonGroup();
for (final Category c : controller.getCategories(elmtType)) {
for (final TransformerCategory c : controller.getCategories(elmtType)) {
//Build button
Icon icon = c.getIcon();
// DecoratedIcon decoratedIcon = getDecoratedIcon(icon, t);
// JToggleButton btn = new JToggleButton(decoratedIcon);
JToggleButton btn = new JToggleButton(icon);
btn.setToolTipText(c.getName());
btn.setToolTipText(c.getDisplayName());
btn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
controller.setSelectedCategory(c);
}
});
btn.setName(c.getName());
btn.setName(c.getDisplayName());
btn.setFocusPainted(false);
buttonGroup.add(btn);
add(btn);
@@ -239,8 +277,8 @@ public class AppearanceToolbar implements AppearanceUIModelListener {
ButtonGroup g = buttonGroups.get(index);
boolean active = model.getSelectedElementClass().equals(elmtType);
g.clearSelection();
Category c = model.getSelectedCategory();
String selected = c.getName();
TransformerCategory c = model.getSelectedCategory();
String selected = c.getDisplayName();
for (Enumeration<AbstractButton> btns = g.getElements(); btns.hasMoreElements();) {
AbstractButton btn = btns.nextElement();
btn.setVisible(active);
@@ -293,7 +331,7 @@ public class AppearanceToolbar implements AppearanceUIModelListener {
if (model != null) {
for (String elmtType : AppearanceUIController.ELEMENT_CLASSES) {
for (Category c : controller.getCategories(elmtType)) {
for (TransformerCategory c : controller.getCategories(elmtType)) {
ButtonGroup buttonGroup = new ButtonGroup();
Map<String, TransformerUI> titles = new LinkedHashMap<String, TransformerUI>();
@@ -333,7 +371,7 @@ public class AppearanceToolbar implements AppearanceUIModelListener {
//Select the right transformer
int index = 0;
for (String elmtType : AppearanceUIController.ELEMENT_CLASSES) {
for (Category c : controller.getCategories(elmtType)) {
for (TransformerCategory c : controller.getCategories(elmtType)) {
ButtonGroup g = buttonGroups.get(index);
boolean active = model.getSelectedElementClass().equals(elmtType) && model.getSelectedCategory().equals(c);
@@ -62,14 +62,43 @@
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
</Container>
<Container class="javax.swing.JPanel" name="centerPanel">
<Container class="javax.swing.JPanel" name="attributePanel">
<Properties>
<Property name="opaque" type="boolean" value="false"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="1.0"/>
<GridBagConstraints gridX="0" gridY="2" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="11" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Component class="javax.swing.JComboBox" name="attibuteBox">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="0"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="4" insetsLeft="4" insetsBottom="4" insetsRight="4" anchor="10" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="centerPanel">
<Properties>
<Property name="opaque" type="boolean" value="false"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="3" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
</Container>
<Container class="javax.swing.JToolBar" name="southToolbar">
<Properties>
@@ -79,7 +108,7 @@
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="3" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="26" weightX="1.0" weightY="0.0"/>
<GridBagConstraints gridX="0" gridY="4" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="26" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
@@ -91,7 +120,7 @@
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="4" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="0.0"/>
<GridBagConstraints gridX="0" gridY="5" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
@@ -41,10 +41,22 @@
*/
package org.gephi.desktop.appearance;
import java.awt.BorderLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.beans.PropertyChangeEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import javax.swing.Box;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JPanel;
import javax.swing.JToggleButton;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import org.gephi.appearance.api.Function;
import org.gephi.appearance.spi.TransformerUI;
import org.gephi.ui.utils.UIUtils;
import org.netbeans.api.settings.ConvertAsProperties;
import org.openide.awt.ActionID;
@@ -65,10 +77,14 @@ import org.openide.windows.TopComponent;
preferredID = "AppearanceTopComponent")
public class AppearanceTopComponent extends TopComponent implements Lookup.Provider, AppearanceUIModelListener {
//Const
private final String NO_SELECTION = NbBundle.getMessage(AppearanceTopComponent.class, "AppearanceTopComponent.choose.text");
//UI
private transient JPanel transformerPanel;
private transient final AppearanceToolbar toolbar;
private transient JToggleButton listButton;
private transient JToggleButton localScaleButton;
private transient ItemListener attributeListener;
//Model
private transient final AppearanceUIController controller;
private transient AppearanceUIModel model;
@@ -79,7 +95,6 @@ public class AppearanceTopComponent extends TopComponent implements Lookup.Provi
controller = Lookup.getDefault().lookup(AppearanceUIController.class);
model = controller.getModel();
controller.addPropertyChangeListener(this);
toolbar = new AppearanceToolbar(controller);
initComponents();
@@ -91,9 +106,41 @@ public class AppearanceTopComponent extends TopComponent implements Lookup.Provi
refreshModel(model);
}
@Override
public void propertyChange(PropertyChangeEvent pce) {
AppearanceUIModel source = (AppearanceUIModel) pce.getSource();
if (pce.getPropertyName().equals(AppearanceUIModelEvent.MODEL)) {
refreshModel(source);
} else if (pce.getPropertyName().equals(AppearanceUIModelEvent.SELECTED_CATEGORY)
|| pce.getPropertyName().equals(AppearanceUIModelEvent.SELECTED_ELEMENT_CLASS)
|| pce.getPropertyName().equals(AppearanceUIModelEvent.SELECTED_TRANSFORMER_UI)) {
refreshCenterPanel();
refreshCombo();
} else if (pce.getPropertyName().equals(AppearanceUIModelEvent.SELECTED_FUNCTION)) {
refreshCenterPanel();
refreshCombo();
}
// if (pce.getPropertyName().equals(RankingUIModel.LIST_VISIBLE)) {
// listButton.setSelected((Boolean) pce.getNewValue());
// if (listResultPanel.isVisible() != model.isListVisible()) {
// listResultPanel.setVisible(model.isListVisible());
// revalidate();
// repaint();
// }
// } else if (pce.getPropertyName().equals(RankingUIModel.BARCHART_VISIBLE)) {
// //barChartButton.setSelected((Boolean)pce.getNewValue());
// } else if (pce.getPropertyName().equals(RankingUIModel.LOCAL_SCALE)) {
// localScaleButton.setSelected((Boolean) pce.getNewValue());
// } else if (pce.getPropertyName().equals(RankingUIModel.LOCAL_SCALE_ENABLED)) {
// localScaleButton.setEnabled((Boolean) pce.getNewValue());
// }
}
public void refreshModel(AppearanceUIModel model) {
this.model = model;
refreshEnable();
refreshCenterPanel();
refreshCombo();
//South visible
/*
@@ -127,28 +174,98 @@ public class AppearanceTopComponent extends TopComponent implements Lookup.Provi
// ((RankingToolbar) categoryToolbar).refreshModel(model);
}
@Override
public void propertyChange(PropertyChangeEvent pce) {
AppearanceUIModel source = (AppearanceUIModel) pce.getSource();
if (pce.getPropertyName().equals(AppearanceUIModelEvent.MODEL)) {
refreshModel(source);
}
// if (pce.getPropertyName().equals(RankingUIModel.LIST_VISIBLE)) {
// listButton.setSelected((Boolean) pce.getNewValue());
// if (listResultPanel.isVisible() != model.isListVisible()) {
// listResultPanel.setVisible(model.isListVisible());
// revalidate();
// repaint();
// }
// } else if (pce.getPropertyName().equals(RankingUIModel.BARCHART_VISIBLE)) {
// //barChartButton.setSelected((Boolean)pce.getNewValue());
// } else if (pce.getPropertyName().equals(RankingUIModel.LOCAL_SCALE)) {
// localScaleButton.setSelected((Boolean) pce.getNewValue());
// } else if (pce.getPropertyName().equals(RankingUIModel.LOCAL_SCALE_ENABLED)) {
// localScaleButton.setEnabled((Boolean) pce.getNewValue());
// }
{
}
private void refreshCenterPanel() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (transformerPanel != null) {
centerPanel.remove(transformerPanel);
transformerPanel = null;
}
if (model != null) {
TransformerUI ui = model.getSelectedTransformerUI();
if (ui != null) {
boolean attribute = model.isAttributeTransformerUI(ui);
attributePanel.setVisible(attribute);
if (attribute) {
Function function = model.getSelectedFunction();
if (function != null) {
ui = function.getUI();
transformerPanel = ui.getPanel(function);
}
} else {
Function function = model.getSelectedFunction();
transformerPanel = ui.getPanel(function);
}
if (transformerPanel != null) {
centerPanel.add(transformerPanel, BorderLayout.CENTER);
}
centerPanel.repaint();
//setCenterPanel
return;
}
}
attributePanel.setVisible(false);
}
});
}
private void refreshCombo() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
final DefaultComboBoxModel comboBoxModel = new DefaultComboBoxModel();
if (model != null) {
TransformerUI ui = model.getSelectedTransformerUI();
if (ui != null && model.isAttributeTransformerUI(ui)) {
//Ranking
Function selectedColumn = model.getSelectedFunction();
attibuteBox.removeItemListener(attributeListener);
comboBoxModel.addElement(NO_SELECTION);
comboBoxModel.setSelectedItem(NO_SELECTION);
List<Function> rows = new ArrayList<Function>();
rows.addAll(model.getFunctions());
Collections.sort(rows, new Comparator<Function>() {
@Override
public int compare(Function o1, Function o2) {
return o1.getUI().getDisplayName().compareTo(o2.getUI().getDisplayName());
}
});
for (Function r : rows) {
comboBoxModel.addElement(r);
if (selectedColumn != null && selectedColumn.equals(r)) {
comboBoxModel.setSelectedItem(r);
}
}
attributeListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (model != null) {
if (!attibuteBox.getSelectedItem().equals(NO_SELECTION)) {
Function selectedItem = (Function) attibuteBox.getSelectedItem();
controller.setSelectedFunction(selectedItem);
} else {
controller.setSelectedFunction(null);
}
}
}
};
attibuteBox.addItemListener(attributeListener);
}
}
attibuteBox.setModel(comboBoxModel);
}
});
}
private void initSouth() {
@@ -228,6 +345,8 @@ public class AppearanceTopComponent extends TopComponent implements Lookup.Provi
mainPanel = new javax.swing.JPanel();
categoryToolbar = toolbar.getCategoryToolbar();
tranformerToolbar = toolbar.getTransformerToolbar();
attributePanel = new javax.swing.JPanel();
attibuteBox = new javax.swing.JComboBox();
centerPanel = new javax.swing.JPanel();
southToolbar = new javax.swing.JToolBar();
controlPanel = new javax.swing.JPanel();
@@ -263,9 +382,31 @@ public class AppearanceTopComponent extends TopComponent implements Lookup.Provi
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints.weightx = 1.0;
mainPanel.add(tranformerToolbar, gridBagConstraints);
attributePanel.setOpaque(false);
attributePanel.setLayout(new java.awt.GridBagLayout());
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
attributePanel.add(attibuteBox, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints.weightx = 1.0;
mainPanel.add(attributePanel, gridBagConstraints);
centerPanel.setOpaque(false);
centerPanel.setLayout(new java.awt.BorderLayout());
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
@@ -276,7 +417,7 @@ public class AppearanceTopComponent extends TopComponent implements Lookup.Provi
southToolbar.setOpaque(false);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3;
gridBagConstraints.gridy = 4;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LAST_LINE_END;
gridBagConstraints.weightx = 1.0;
@@ -341,7 +482,7 @@ public class AppearanceTopComponent extends TopComponent implements Lookup.Provi
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 4;
gridBagConstraints.gridy = 5;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0;
mainPanel.add(controlPanel, gridBagConstraints);
@@ -350,6 +491,8 @@ public class AppearanceTopComponent extends TopComponent implements Lookup.Provi
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton applyButton;
private javax.swing.JComboBox attibuteBox;
private javax.swing.JPanel attributePanel;
private javax.swing.JToggleButton autoApplyButton;
private javax.swing.JToolBar autoApplyToolbar;
private javax.swing.JToolBar categoryToolbar;
@@ -1,6 +1,43 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.desktop.appearance;
@@ -14,8 +51,9 @@ import java.util.Map;
import java.util.Set;
import org.gephi.appearance.api.AppearanceController;
import org.gephi.appearance.api.AppearanceModel;
import org.gephi.appearance.spi.Category;
import org.gephi.appearance.api.Function;
import org.gephi.appearance.spi.Transformer;
import org.gephi.appearance.spi.TransformerCategory;
import org.gephi.appearance.spi.TransformerUI;
import org.gephi.project.api.ProjectController;
import org.gephi.project.api.Workspace;
@@ -35,15 +73,16 @@ public class AppearanceUIController {
protected static final String EDGE_ELEMENT = "edges";
protected static final String[] ELEMENT_CLASSES = {NODE_ELEMENT, EDGE_ELEMENT};
//Transformers
protected final Map<String, Map<Category, Set<TransformerUI>>> transformers;
protected final Map<String, Map<TransformerCategory, Set<TransformerUI>>> transformers;
//Architecture
protected final AppearanceController appearanceController;
private final Set<AppearanceUIModelListener> listeners;
//Model
private AppearanceUIModel model;
public AppearanceUIController() {
final ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
final AppearanceController ac = Lookup.getDefault().lookup(AppearanceController.class);
appearanceController = Lookup.getDefault().lookup(AppearanceController.class);
pc.addWorkspaceListener(new WorkspaceListener() {
@Override
public void initialize(Workspace workspace) {
@@ -54,7 +93,7 @@ public class AppearanceUIController {
AppearanceUIModel oldModel = model;
model = workspace.getLookup().lookup(AppearanceUIModel.class);
if (model == null) {
AppearanceModel appearanceModel = ac.getModel(workspace);
AppearanceModel appearanceModel = appearanceController.getModel(workspace);
model = new AppearanceUIModel(AppearanceUIController.this, appearanceModel);
workspace.add(model);
}
@@ -82,7 +121,7 @@ public class AppearanceUIController {
if (pc.getCurrentWorkspace() != null) {
model = pc.getCurrentWorkspace().getLookup().lookup(AppearanceUIModel.class);
if (model == null) {
AppearanceModel appearanceModel = ac.getModel(pc.getCurrentWorkspace());
AppearanceModel appearanceModel = appearanceController.getModel(pc.getCurrentWorkspace());
model = new AppearanceUIModel(this, appearanceModel);
pc.getCurrentWorkspace().add(model);
}
@@ -90,43 +129,45 @@ public class AppearanceUIController {
listeners = Collections.synchronizedSet(new HashSet<AppearanceUIModelListener>());
transformers = new HashMap<String, Map<Category, Set<TransformerUI>>>();
transformers = new HashMap<String, Map<TransformerCategory, Set<TransformerUI>>>();
for (String ec : ELEMENT_CLASSES) {
transformers.put(ec, new LinkedHashMap<Category, Set<TransformerUI>>());
transformers.put(ec, new LinkedHashMap<TransformerCategory, Set<TransformerUI>>());
}
//Register transformers
Collection<? extends TransformerUI> trs = Lookup.getDefault().lookupAll(TransformerUI.class);
for (TransformerUI t : trs) {
for (Category c : t.getCategories()) {
Transformer transformer = ac.getTransformer(t);
if (transformer != null) {
if (c.isNode()) {
Set<TransformerUI> uis = transformers.get(NODE_ELEMENT).get(c);
if (uis == null) {
uis = new LinkedHashSet<TransformerUI>();
transformers.get(NODE_ELEMENT).put(c, uis);
}
uis.add(t);
Map<Class, Transformer> tMap = new HashMap<Class, Transformer>();
for (Transformer t : Lookup.getDefault().lookupAll(Transformer.class)) {
tMap.put(t.getClass(), t);
}
for (TransformerUI ui : Lookup.getDefault().lookupAll(TransformerUI.class)) {
Transformer t = tMap.get(ui.getTransformerClass());
if (t != null) {
TransformerCategory c = ui.getCategory();
if (t.isNode()) {
Set<TransformerUI> uis = transformers.get(NODE_ELEMENT).get(c);
if (uis == null) {
uis = new LinkedHashSet<TransformerUI>();
transformers.get(NODE_ELEMENT).put(c, uis);
}
if (c.isEdge()) {
Set<TransformerUI> uis = transformers.get(EDGE_ELEMENT).get(c);
if (uis == null) {
uis = new LinkedHashSet<TransformerUI>();
transformers.get(EDGE_ELEMENT).put(c, uis);
}
uis.add(t);
uis.add(ui);
}
if (t.isEdge()) {
Set<TransformerUI> uis = transformers.get(EDGE_ELEMENT).get(c);
if (uis == null) {
uis = new LinkedHashSet<TransformerUI>();
transformers.get(EDGE_ELEMENT).put(c, uis);
}
uis.add(ui);
}
}
}
}
public Collection<Category> getCategories(String elementClass) {
public Collection<TransformerCategory> getCategories(String elementClass) {
return transformers.get(elementClass).keySet();
}
public Collection<TransformerUI> getTransformerUIs(String elementClass, Category category) {
public Collection<TransformerUI> getTransformerUIs(String elementClass, TransformerCategory category) {
return transformers.get(elementClass).get(category);
}
@@ -158,9 +199,9 @@ public class AppearanceUIController {
}
}
public void setSelectedCategory(Category category) {
public void setSelectedCategory(TransformerCategory category) {
if (model != null) {
Category oldValue = model.getSelectedCategory();
TransformerCategory oldValue = model.getSelectedCategory();
if (!oldValue.equals(category)) {
model.setSelectedCategory(category);
firePropertyChangeEvent(AppearanceUIModelEvent.SELECTED_CATEGORY, oldValue, category);
@@ -178,12 +219,22 @@ public class AppearanceUIController {
}
}
protected Category getFirstCategory(String elementClass) {
return transformers.get(elementClass).keySet().toArray(new Category[0])[0];
public void setSelectedFunction(Function function) {
if (model != null) {
Function oldValue = model.getSelectedFunction();
if ((oldValue == null && function != null) || (oldValue != null && function == null) || !oldValue.equals(function)) {
model.setSelectedFunction(function);
firePropertyChangeEvent(AppearanceUIModelEvent.SELECTED_FUNCTION, oldValue, function);
}
}
}
protected TransformerUI getFirstTransformerUI(String elementClass, Category category) {
Map<Category, Set<TransformerUI>> e = transformers.get(elementClass);
protected TransformerCategory getFirstCategory(String elementClass) {
return transformers.get(elementClass).keySet().toArray(new TransformerCategory[0])[0];
}
protected TransformerUI getFirstTransformerUI(String elementClass, TransformerCategory category) {
Map<TransformerCategory, Set<TransformerUI>> e = transformers.get(elementClass);
return e.get(category).toArray(new TransformerUI[0])[0];
}
@@ -1,13 +1,59 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.desktop.appearance;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.gephi.appearance.api.AppearanceModel;
import org.gephi.appearance.spi.Category;
import org.gephi.appearance.api.Function;
import org.gephi.appearance.spi.PartitionTransformer;
import org.gephi.appearance.spi.RankingTransformer;
import org.gephi.appearance.spi.Transformer;
import org.gephi.appearance.spi.TransformerCategory;
import org.gephi.appearance.spi.TransformerUI;
import static org.gephi.desktop.appearance.AppearanceUIController.ELEMENT_CLASSES;
@@ -18,26 +64,61 @@ import static org.gephi.desktop.appearance.AppearanceUIController.ELEMENT_CLASSE
public class AppearanceUIModel {
protected final AppearanceUIController controller;
protected final Map<String, Map<Category, TransformerUI>> selectedTransformerUI;
protected final Map<String, Category> selectedCategory;
protected final AppearanceModel appearanceModel;
protected final Map<String, Map<TransformerCategory, TransformerUI>> selectedTransformerUI;
protected final Map<String, Map<TransformerUI, Function>> selectedFunction;
protected final Map<String, TransformerCategory> selectedCategory;
protected String selectedElementClass = AppearanceUIController.NODE_ELEMENT;
protected Transformer selectedTransformer;
public AppearanceUIModel(AppearanceUIController controller, AppearanceModel model) {
this.controller = controller;
this.appearanceModel = model;
//Init categories
selectedCategory = new HashMap<String, Category>();
//Init maps
selectedCategory = new HashMap<String, TransformerCategory>();
selectedTransformerUI = new HashMap<String, Map<TransformerCategory, TransformerUI>>();
selectedFunction = new HashMap<String, Map<TransformerUI, Function>>();
//Init selected
for (String ec : ELEMENT_CLASSES) {
selectedCategory.put(ec, controller.getFirstCategory(ec));
initSelectedTransformerUIs(ec);
refreshSelectedFunctions(ec);
}
}
private void initSelectedTransformerUIs(String elementClass) {
Map<TransformerCategory, TransformerUI> newMap = new HashMap<TransformerCategory, TransformerUI>();
for (Function func : elementClass.equals(AppearanceUIController.NODE_ELEMENT) ? appearanceModel.getNodeFunctions() : appearanceModel.getEdgeFunctions()) {
TransformerUI ui = func.getUI();
if (ui != null) {
TransformerCategory cat = ui.getCategory();
if (!newMap.containsKey(cat)) {
newMap.put(cat, ui);
}
if (!selectedCategory.containsKey(elementClass)) {
selectedCategory.put(elementClass, cat);
}
}
}
selectedTransformerUI.put(elementClass, newMap);
selectedFunction.put(elementClass, new HashMap<TransformerUI, Function>());
}
private void refreshSelectedFunctions(String elementClass) {
Set<Function> functionSet = new HashSet<Function>();
for (Function func : elementClass.equals(AppearanceUIController.NODE_ELEMENT) ? appearanceModel.getNodeFunctions() : appearanceModel.getEdgeFunctions()) {
TransformerUI ui = func.getUI();
if (ui != null) {
functionSet.add(func);
}
}
//Init transformers
selectedTransformerUI = new HashMap<String, Map<Category, TransformerUI>>();
for (String ec : ELEMENT_CLASSES) {
Map<Category, TransformerUI> m = new HashMap<Category, TransformerUI>();
selectedTransformerUI.put(ec, m);
for (Category c : controller.getCategories(ec)) {
m.put(c, controller.getFirstTransformerUI(ec, c));
for (Function func : functionSet) {
Function oldFunc = selectedFunction.get(elementClass).get(func.getUI());
if (oldFunc == null || !functionSet.contains(oldFunc)) {
selectedFunction.get(elementClass).put(func.getUI(), func);
}
}
}
@@ -52,7 +133,7 @@ public class AppearanceUIModel {
return selectedElementClass;
}
public Category getSelectedCategory() {
public TransformerCategory getSelectedCategory() {
return selectedCategory.get(selectedElementClass);
}
@@ -60,15 +141,106 @@ public class AppearanceUIModel {
return selectedTransformerUI.get(selectedElementClass).get(getSelectedCategory());
}
public Function getSelectedFunction() {
return selectedFunction.get(selectedElementClass).get(getSelectedTransformerUI());
}
public Collection<Function> getFunctions() {
List<Function> functions = new ArrayList<Function>();
for (Function func : selectedElementClass.equalsIgnoreCase(AppearanceUIController.NODE_ELEMENT) ? appearanceModel.getNodeFunctions() : appearanceModel.getEdgeFunctions()) {
TransformerUI ui = func.getUI();
if (ui != null && ui.getDisplayName().equals(getSelectedTransformerUI().getDisplayName())) {
if (ui.getCategory().equals(selectedCategory.get(selectedElementClass))) {
functions.add(func);
}
}
}
return functions;
}
protected boolean isAttributeTransformerUI(TransformerUI ui) {
Class transformerClass = ui.getTransformerClass();
if (RankingTransformer.class.isAssignableFrom(transformerClass) || PartitionTransformer.class.isAssignableFrom(transformerClass)) {
return true;
}
return false;
}
protected void setSelectedElementClass(String selectedElementClass) {
this.selectedElementClass = selectedElementClass;
}
public void setSelectedCategory(Category category) {
protected void setSelectedCategory(TransformerCategory category) {
selectedCategory.put(selectedElementClass, category);
}
protected void setSelectedTransformerUI(TransformerUI transformerUI) {
selectedTransformerUI.get(selectedElementClass).put(getSelectedCategory(), transformerUI);
}
protected void setSelectedFunction(Function function) {
selectedFunction.get(selectedElementClass).put(getSelectedTransformerUI(), function);
}
// protected void setSelectedTransformerUI(TransformerUI transformerUI) {
// selectedTransformerUI.get(selectedElementClass).put(getSelectedCategory(), transformerUI);
// if (transformerUI instanceof SimpleTransformerUI) {
// if (selectedTransformer != null) {
// unsetupTransformer(selectedTransformer);
// }
// selectedTransformer = controller.appearanceController.getTransformer(transformerUI);
// setupTransformer(selectedTransformer);
// } else {
// //TODO
// }
// }
// public void setupTransformer(Transformer transformer) {
// for (Method m : transformer.getClass().getMethods()) {
// if (isSetter(m)) {
// Class paramClass = m.getParameterTypes()[0];
// if (paramClass.isPrimitive() || Serializable.class.isAssignableFrom(paramClass)) {
// System.out.println("Setting to method " + m.getName());
// }
// }
// }
// }
//
// public void unsetupTransformer(Transformer transformer) {
// for (Method m : transformer.getClass().getMethods()) {
// if (isGetter(m)) {
// Class returnClass = m.getReturnType();
// if (returnClass.isPrimitive() || Serializable.class.isAssignableFrom(returnClass)) {
// try {
// Object res = m.invoke(transformer);
// if (res != null) {
// System.out.println("Extracted " + res + " from method " + m.getName());
// }
// } catch (Exception ex) {
// ex.printStackTrace();
// }
// }
// }
// }
// }
//
// public static boolean isGetter(Method method) {
// if (Modifier.isPublic(method.getModifiers())
// && method.getParameterTypes().length == 0) {
// if (method.getName().matches("^get[A-Z].*")
// && !method.getReturnType().equals(void.class)) {
// return true;
// }
// if (method.getName().matches("^is[A-Z].*")
// && method.getReturnType().equals(boolean.class)) {
// return true;
// }
// }
// return false;
// }
//
// public static boolean isSetter(Method method) {
// return Modifier.isPublic(method.getModifiers())
// && method.getReturnType().equals(void.class)
// && method.getParameterTypes().length == 1
// && method.getName().matches("^set[A-Z].*");
// }
}
@@ -1,6 +1,43 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.desktop.appearance;
@@ -16,6 +53,8 @@ public class AppearanceUIModelEvent extends PropertyChangeEvent {
public static String SELECTED_ELEMENT_CLASS = "selectedElementClass";
public static String SELECTED_CATEGORY = "selectedCategory";
public static String SELECTED_TRANSFORMER_UI = "selectedTransformerUI";
public static String SELECTED_FUNCTION = "selectedFunction";
public static String ATTRIBUTE_LIST = "attributeList";
public AppearanceUIModelEvent(Object source, String propertyName,
Object oldValue, Object newValue) {
@@ -1,6 +1,43 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 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 2013 Gephi Consortium.
*/
package org.gephi.desktop.appearance;

Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais