提交 3ebffd48 编写于 作者: M Mathieu Bastian

Update LayoutAPI and LayoutPlugin to new GraphAPI

上级 5e7eb963
......@@ -73,13 +73,13 @@ import org.openide.util.Lookup;
public class LayoutModelImpl implements LayoutModel {
//Listeners
private List<PropertyChangeListener> listeners;
private final List<PropertyChangeListener> listeners;
//Data
private final Map<LayoutPropertyKey, Object> savedProperties;
private Layout selectedLayout;
private LayoutBuilder selectedBuilder;
private Map<LayoutPropertyKey, Object> savedProperties;
//Util
private LongTaskExecutor executor;
private final LongTaskExecutor executor;
public LayoutModelImpl() {
listeners = new ArrayList<PropertyChangeListener>();
......@@ -87,25 +87,30 @@ public class LayoutModelImpl implements LayoutModel {
executor = new LongTaskExecutor(true, "layout", 5);
executor.setLongTaskListener(new LongTaskListener() {
@Override
public void taskFinished(LongTask task) {
setRunning(false);
}
});
executor.setDefaultErrorHandler(new LongTaskErrorHandler() {
@Override
public void fatalError(Throwable t) {
Logger.getLogger("").log(Level.SEVERE, "", t.getCause() != null ? t.getCause() : t);
}
});
}
@Override
public Layout getSelectedLayout() {
return selectedLayout;
}
@Override
public LayoutBuilder getSelectedBuilder() {
return selectedBuilder;
}
@Override
public Layout getLayout(LayoutBuilder layoutBuilder) {
Layout layout = layoutBuilder.buildLayout();
selectedBuilder = layoutBuilder;
......@@ -130,11 +135,12 @@ public class LayoutModelImpl implements LayoutModel {
public void injectGraph() {
GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
if (selectedLayout != null && graphController.getModel() != null) {
selectedLayout.setGraphModel(graphController.getModel());
if (selectedLayout != null && graphController.getGraphModel() != null) {
selectedLayout.setGraphModel(graphController.getGraphModel());
}
}
@Override
public boolean isRunning() {
return executor.isRunning();
}
......@@ -143,12 +149,14 @@ public class LayoutModelImpl implements LayoutModel {
firePropertyChangeEvent(RUNNING, !running, running);
}
@Override
public void addPropertyChangeListener(PropertyChangeListener listener) {
if (!listeners.contains(listener)) {
listeners.add(listener);
}
}
@Override
public void removePropertyChangeListener(PropertyChangeListener listener) {
listeners.remove(listener);
}
......
/*
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.layout.plugin;
import org.gephi.dynamic.api.DynamicController;
import org.gephi.dynamic.api.DynamicModel;
import org.gephi.graph.api.GraphModel;
import org.gephi.layout.spi.Layout;
import org.gephi.layout.spi.LayoutBuilder;
import org.gephi.project.api.Workspace;
import org.openide.util.Lookup;
/**
* Base class for layout algorithms.
*
* @author Helder Suzuki <heldersuzuki@gephi.org>
*/
public abstract class AbstractLayout implements Layout {
private final LayoutBuilder layoutBuilder;
protected GraphModel graphModel;
protected DynamicModel dynamicModel;
private boolean converged;
public AbstractLayout(LayoutBuilder layoutBuilder) {
this.layoutBuilder = layoutBuilder;
}
@Override
public LayoutBuilder getBuilder() {
return layoutBuilder;
}
@Override
public void setGraphModel(GraphModel graphModel) {
this.graphModel = graphModel;
Workspace workspace = graphModel.getWorkspace();
DynamicController dynamicController = Lookup.getDefault().lookup(DynamicController.class);
if (dynamicController != null && workspace != null) {
dynamicModel = dynamicController.getModel(workspace);
}
}
@Override
public boolean canAlgo() {
return !isConverged() && graphModel != null;
}
......
/*
Copyright 2008-2010 Gephi
Authors : Mathieu Jacomy
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.
*/
Copyright 2008-2010 Gephi
Authors : Mathieu Jacomy
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.layout.plugin;
import org.gephi.graph.api.NodeData;
import org.gephi.graph.api.Spatial;
import org.gephi.graph.api.Node;
/**
*
......@@ -50,11 +49,11 @@ import org.gephi.graph.api.Spatial;
*/
public class ForceVectorUtils {
public static float distance(Spatial n1, Spatial n2) {
public static float distance(Node n1, Node n2) {
return (float) Math.hypot(n1.x() - n2.x(), n1.y() - n2.y());
}
public static void fcBiRepulsor(NodeData N1, NodeData N2, double c) {
public static void fcBiRepulsor(Node N1, Node N2, double c) {
double xDist = N1.x() - N2.x(); // distance en x entre les deux noeuds
double yDist = N1.y() - N2.y();
double dist = (float) Math.sqrt(xDist * xDist + yDist * yDist); // distance tout court
......@@ -73,7 +72,7 @@ public class ForceVectorUtils {
}
}
public static void fcBiRepulsor_y(NodeData N1, NodeData N2, double c, double verticalization) {
public static void fcBiRepulsor_y(Node N1, Node N2, double c, double verticalization) {
double xDist = N1.x() - N2.x(); // distance en x entre les deux noeuds
double yDist = N1.y() - N2.y();
double dist = (float) Math.sqrt(xDist * xDist + yDist * yDist); // distance tout court
......@@ -92,10 +91,10 @@ public class ForceVectorUtils {
}
}
public static void fcBiRepulsor_noCollide(NodeData N1, NodeData N2, double c) {
public static void fcBiRepulsor_noCollide(Node N1, Node N2, double c) {
double xDist = N1.x() - N2.x(); // distance en x entre les deux noeuds
double yDist = N1.y() - N2.y();
double dist = (float) Math.sqrt(xDist * xDist + yDist * yDist) - N1.getSize() - N2.getSize(); // distance (from the border of each node)
double dist = (float) Math.sqrt(xDist * xDist + yDist * yDist) - N1.size() - N2.size(); // distance (from the border of each node)
if (dist > 0) {
double f = repulsion(c, dist);
......@@ -122,7 +121,7 @@ public class ForceVectorUtils {
}
}
public static void fcUniRepulsor(NodeData N1, NodeData N2, double c) {
public static void fcUniRepulsor(Node N1, Node N2, double c) {
double xDist = N1.x() - N2.x(); // distance en x entre les deux noeuds
double yDist = N1.y() - N2.y();
double dist = (float) Math.sqrt(xDist * xDist + yDist * yDist); // distance tout court
......@@ -137,7 +136,7 @@ public class ForceVectorUtils {
}
}
public static void fcBiAttractor(NodeData N1, NodeData N2, double c) {
public static void fcBiAttractor(Node N1, Node N2, double c) {
double xDist = N1.x() - N2.x(); // distance en x entre les deux noeuds
double yDist = N1.y() - N2.y();
double dist = (float) Math.sqrt(xDist * xDist + yDist * yDist); // distance tout court
......@@ -156,10 +155,10 @@ public class ForceVectorUtils {
}
}
public static void fcBiAttractor_noCollide(NodeData N1, NodeData N2, double c) {
public static void fcBiAttractor_noCollide(Node N1, Node N2, double c) {
double xDist = N1.x() - N2.x(); // distance en x entre les deux noeuds
double yDist = N1.y() - N2.y();
double dist = (float) Math.sqrt(xDist * xDist + yDist * yDist) - N1.getSize() - N2.getSize(); // distance (from the border of each node)
double dist = (float) Math.sqrt(xDist * xDist + yDist * yDist) - N1.size() - N2.size(); // distance (from the border of each node)
if (dist > 0) {
double f = attraction(c, dist);
......@@ -175,7 +174,7 @@ public class ForceVectorUtils {
}
}
public static void fcBiFlatAttractor(NodeData N1, NodeData N2, double c) {
public static void fcBiFlatAttractor(Node N1, Node N2, double c) {
double xDist = N1.x() - N2.x(); // distance en x entre les deux noeuds
double yDist = N1.y() - N2.y();
double dist = (float) Math.sqrt(xDist * xDist + yDist * yDist); // distance tout court
......@@ -194,7 +193,7 @@ public class ForceVectorUtils {
}
}
public static void fcUniAttractor(NodeData N1, NodeData N2, float c) {
public static void fcUniAttractor(Node N1, Node N2, float c) {
double xDist = N1.x() - N2.x(); // distance en x entre les deux noeuds
double yDist = N1.y() - N2.y();
double dist = (float) Math.sqrt(xDist * xDist + yDist * yDist); // distance tout court
......
/*
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.
*/
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.layout.plugin.force;
import org.gephi.graph.api.Spatial;
import org.gephi.graph.api.Node;
import org.gephi.layout.plugin.ForceVectorUtils;
/**
......@@ -50,11 +50,11 @@ import org.gephi.layout.plugin.ForceVectorUtils;
*/
public abstract class AbstractForce {
public ForceVector calculateForce(Spatial node1, Spatial node2) {
public ForceVector calculateForce(Node node1, Node node2) {
return calculateForce(node1, node2,
ForceVectorUtils.distance(node1, node2));
ForceVectorUtils.distance(node1, node2));
}
public abstract ForceVector calculateForce(Spatial node1, Spatial node2,
float distance);
public abstract ForceVector calculateForce(Node node1, Node node2,
float distance);
}
/*
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.
*/
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.layout.plugin.force;
import org.gephi.graph.api.NodeData;
import org.gephi.graph.api.Node;
/**
*
......@@ -51,5 +51,5 @@ public interface Displacement {
public void setStep(float step);
public void moveNode(NodeData node, ForceVector forceData);
public void moveNode(Node node, ForceVector forceData);
}
/*
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.
*/
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.layout.plugin.force;
import org.gephi.graph.spi.LayoutData;
import org.gephi.graph.api.Spatial;
/**
*
* @author Helder Suzuki <heldersuzuki@gephi.org>
*/
public class ForceVector implements Spatial, LayoutData {
public class ForceVector implements LayoutData {
protected float x;
protected float y;
......
/*
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.
*/
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.layout.plugin.force;
import org.gephi.graph.api.NodeData;
import org.gephi.graph.api.Node;
/**
* The movement of the node is in the direction of the force and it's proportional
* to is module.
* The movement of the node is in the direction of the force and it's
* proportional to is module.
*
* @author Helder Suzuki <heldersuzuki@gephi.org>
*/
public class ProportionalDisplacement implements Displacement {
......@@ -56,6 +57,7 @@ public class ProportionalDisplacement implements Displacement {
this.step = step;
}
@Override
public void setStep(float step) {
this.step = step;
}
......@@ -65,7 +67,8 @@ public class ProportionalDisplacement implements Displacement {
return ret;
}
public void moveNode(NodeData node, ForceVector forceData) {
@Override
public void moveNode(Node node, ForceVector forceData) {
ForceVector displacement = new ForceVector(forceData);
displacement.multiply(step);
......
/*
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.
*/
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.layout.plugin.force;
import org.gephi.graph.api.NodeData;
import org.gephi.graph.api.Node;
/**
* The node is moved a fixed distance (step) in the direction of the force.
* The node is moved a fixed distance (step) in the direction of the force.
*
* @author Helder Suzuki <heldersuzuki@gephi.org>
*/
public class StepDisplacement implements Displacement {
......@@ -60,7 +61,8 @@ public class StepDisplacement implements Displacement {
return ret;
}
public void moveNode(NodeData node, ForceVector forceData) {
@Override
public void moveNode(Node node, ForceVector forceData) {
ForceVector displacement = forceData.normalize();
displacement.multiply(step);
......@@ -75,7 +77,8 @@ public class StepDisplacement implements Displacement {
}
}
@Override
public void setStep(float step) {
this.step = step;
}
}
\ No newline at end of file
}
/*
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.
*/
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.layout.plugin.force.quadtree;
import org.gephi.graph.api.Spatial;
import org.gephi.graph.api.Node;
import org.gephi.layout.plugin.ForceVectorUtils;
import org.gephi.layout.plugin.force.AbstractForce;
import org.gephi.layout.plugin.force.ForceVector;
/**
* Barnes-Hut's O(n log n) force calculation algorithm.
*
* @author Helder Suzuki <heldersuzuki@gephi.org>
*/
public class BarnesHut {
......@@ -64,7 +65,7 @@ public class BarnesHut {
/* Calculates the ForceVector on node against every other node represented
* in the tree with respect to force.
*/
public ForceVector calculateForce(Spatial node, QuadTree tree) {
public ForceVector calculateForce(Node node, QuadTree tree) {
if (tree.mass() <= 0) {
return null;
}
......
/*
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.
*/
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.layout.plugin.force.quadtree;
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import org.gephi.graph.api.HierarchicalGraph;
import java.util.Set;
import org.gephi.attribute.api.Column;
import org.gephi.graph.api.Graph;
import org.gephi.graph.api.Node;
import org.gephi.graph.api.Spatial;
import org.gephi.graph.api.NodeProperties;
import org.gephi.graph.api.TextProperties;
import org.gephi.graph.spi.LayoutData;
/**
* @author Helder Suzuki <heldersuzuki@gephi.org>
*/
public class QuadTree implements Spatial {
public class QuadTree implements Node {
private float posX;
private float posY;
......@@ -64,23 +69,23 @@ public class QuadTree implements Spatial {
private boolean isLeaf;
public static final float eps = (float) 1e-6;
public static QuadTree buildTree(HierarchicalGraph graph, int maxLevel) {
public static QuadTree buildTree(Graph graph, int maxLevel) {
float minX = Float.POSITIVE_INFINITY;
float maxX = Float.NEGATIVE_INFINITY;
float minY = Float.POSITIVE_INFINITY;
float maxY = Float.NEGATIVE_INFINITY;
for (Node node : graph.getTopNodes()) {
minX = Math.min(minX, node.getNodeData().x());
maxX = Math.max(maxX, node.getNodeData().x());
minY = Math.min(minY, node.getNodeData().y());
maxY = Math.max(maxY, node.getNodeData().y());
for (Node node : graph.getNodes()) {
minX = Math.min(minX, node.x());
maxX = Math.max(maxX, node.x());
minY = Math.min(minY, node.y());
maxY = Math.max(maxY, node.y());
}
float size = Math.max(maxY - minY, maxX - minX);
QuadTree tree = new QuadTree(minX, minY, size, maxLevel);
for (Node node : graph.getTopNodes()) {
tree.addNode(node.getNodeData());
for (Node node : graph.getNodes()) {
tree.addNode(node);
}
return tree;
......@@ -96,6 +101,7 @@ public class QuadTree implements Spatial {
add = new FirstAdd();
}
@Override
public float size() {
return size;
}
......@@ -105,17 +111,17 @@ public class QuadTree implements Spatial {
children = new ArrayList<QuadTree>();
children.add(new QuadTree(posX + childSize, posY + childSize,
childSize, maxLevel - 1));
childSize, maxLevel - 1));
children.add(new QuadTree(posX, posY + childSize,
childSize, maxLevel - 1));
childSize, maxLevel - 1));
children.add(new QuadTree(posX, posY, childSize, maxLevel - 1));
children.add(new QuadTree(posX + childSize, posY,
childSize, maxLevel - 1));
childSize, maxLevel - 1));
isLeaf = false;
}
private boolean addToChildren(Spatial node) {
private boolean addToChildren(NodeProperties node) {
for (QuadTree q : children) {
if (q.addNode(node)) {
return true;
......@@ -124,7 +130,7 @@ public class QuadTree implements Spatial {
return false;
}
private void assimilateNode(Spatial node) {
private void assimilateNode(NodeProperties node) {
centerMassX = (mass * centerMassX + node.x()) / (mass + 1);
centerMassY = (mass * centerMassY + node.y()) / (mass + 1);
mass++;
......@@ -134,10 +140,12 @@ public class QuadTree implements Spatial {
return children;
}
@Override
public float x() {
return centerMassX;
}
@Override
public float y() {
return centerMassY;
}
......@@ -146,13 +154,14 @@ public class QuadTree implements Spatial {
return mass;
}
@Override
public float z() {
throw new UnsupportedOperationException("Not supported yet.");
}
public boolean addNode(Spatial node) {
if (posX <= node.x() && node.x() <= posX + size &&
posY <= node.y() && node.y() <= posY + size) {
public boolean addNode(NodeProperties node) {
if (posX <= node.x() && node.x() <= posX + size
&& posY <= node.y() && node.y() <= posY + size) {
return add.addNode(node);
} else {
return false;
......@@ -166,9 +175,210 @@ public class QuadTree implements Spatial {
return isLeaf;
}
@Override
public float r() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public float g() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public float b() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getRGBA() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Color getColor() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public float alpha() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public float radius() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isFixed() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T extends LayoutData> T getLayoutData() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public TextProperties getTextProperties() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setX(float x) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setY(float y) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setZ(float z) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setPosition(float x, float y) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setPosition(float x, float y, float z) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setR(float r) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setG(float g) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setB(float b) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setAlpha(float a) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setColor(Color color) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setSize(float size) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setFixed(boolean fixed) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setLayoutData(LayoutData layoutData) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Object getId() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getLabel() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Object getAttribute(String key) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Object getAttribute(Column column) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Object[] getAttributes() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Set<String> getAttributeKeys() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Object removeAttribute(String key) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Object removeAttribute(Column column) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setLabel(String label) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setAttribute(String key, Object value) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setAttribute(Column column, Object value) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setAttribute(String key, Object value, double timestamp) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setAttribute(Column column, Object value, double timestamp) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean addTimestamp(double timestamp) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean removeTimestamp(double timestamp) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public double[] getTimestamps() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void clearAttributes() {
throw new UnsupportedOperationException("Not supported yet.");
}
class FirstAdd implements AddBehaviour {
public boolean addNode(Spatial node) {
@Override
public boolean addNode(NodeProperties node) {
mass = 1;
centerMassX = node.x();
centerMassY = node.y();
......@@ -185,7 +395,8 @@ public class QuadTree implements Spatial {
class SecondAdd implements AddBehaviour {
public boolean addNode(Spatial node) {
@Override
public boolean addNode(NodeProperties node) {
divideTree();
add = new RootAdd();
/* This QuadTree represents one node, add it to a child accordingly
......@@ -197,7 +408,8 @@ public class QuadTree implements Spatial {
class LeafAdd implements AddBehaviour {
public boolean addNode(Spatial node) {
@Override
public boolean addNode(NodeProperties node) {
assimilateNode(node);
return true;
}
......@@ -205,7 +417,8 @@ public class QuadTree implements Spatial {
class RootAdd implements AddBehaviour {
public boolean addNode(Spatial node) {
@Override
public boolean addNode(NodeProperties node) {
assimilateNode(node);
return addToChildren(node);
}
......@@ -214,5 +427,5 @@ public class QuadTree implements Spatial {
interface AddBehaviour {
public boolean addNode(Spatial node);
}
\ No newline at end of file
public boolean addNode(NodeProperties node);
}
/*
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.
*/
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.layout.plugin.force.yifanHu;
import javax.swing.Icon;
......@@ -54,42 +54,50 @@ import org.openide.util.lookup.ServiceProvider;
*
* @author Helder Suzuki <heldersuzuki@gephi.org>
*/
@ServiceProvider(service=LayoutBuilder.class)
@ServiceProvider(service = LayoutBuilder.class)
public class YifanHu implements LayoutBuilder {
private YifanHuLayoutUI ui = new YifanHuLayoutUI();
@Override
public YifanHuLayout buildLayout() {
YifanHuLayout layout = new YifanHuLayout(this, new StepDisplacement(1f));
return layout;
}
@Override
public String getName() {
return NbBundle.getMessage(YifanHu.class, "YifanHu.name");
}
@Override
public LayoutUI getUI() {
return ui;
}
private static class YifanHuLayoutUI implements LayoutUI {
@Override
public String getDescription() {
return NbBundle.getMessage(YifanHu.class, "YifanHu.description");
}
@Override
public Icon getIcon() {
return null;
}
@Override
public JPanel getSimplePanel(Layout layout) {
return null;
}
@Override
public int getQualityRank() {
return 3;
}
@Override
public int getSpeedRank() {
return 4;
}
......
/*
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.
*/
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.layout.plugin.force.yifanHu;
import java.util.ArrayList;
import java.util.List;
import org.gephi.graph.api.Edge;
import org.gephi.graph.api.HierarchicalGraph;
import org.gephi.graph.api.Graph;
import org.gephi.graph.api.Node;
import org.gephi.graph.api.NodeData;
import org.gephi.graph.api.Spatial;
import org.gephi.layout.plugin.AbstractLayout;
import org.gephi.layout.plugin.GraphUtils;
import org.gephi.layout.plugin.ForceVectorUtils;
import org.gephi.layout.plugin.force.AbstractForce;
import org.gephi.layout.plugin.force.Displacement;
import org.gephi.layout.plugin.force.ForceVector;
import org.gephi.layout.plugin.force.quadtree.BarnesHut;
import org.gephi.layout.plugin.force.quadtree.QuadTree;
import org.gephi.layout.spi.Layout;
import org.gephi.layout.spi.LayoutBuilder;
import org.gephi.layout.spi.LayoutProperty;
import org.gephi.layout.plugin.force.quadtree.QuadTree;
import org.openide.util.NbBundle;
/**
* Hu's basic algorithm
*
* @author Helder Suzuki <heldersuzuki@gephi.org>
*/
public class YifanHuLayout extends AbstractLayout implements Layout {
......@@ -79,7 +78,7 @@ public class YifanHuLayout extends AbstractLayout implements Layout {
private Displacement displacement;
private double energy0;
private double energy;
private HierarchicalGraph graph;
private Graph graph;
public YifanHuLayout(LayoutBuilder layoutBuilder, Displacement displacement) {
super(layoutBuilder);
......@@ -128,7 +127,7 @@ public class YifanHuLayout extends AbstractLayout implements Layout {
setStepRatio((float) 0.95);
setRelativeStrength((float) 0.2);
if (graph != null) {
setOptimalDistance((float) (Math.pow(getRelativeStrength(), 1.0 / 3) * GraphUtils.getAverageEdgeLength(graph)));
setOptimalDistance((float) (Math.pow(getRelativeStrength(), 1.0 / 3) * getAverageEdgeLength(graph)));
} else {
setOptimalDistance(100.0f);
}
......@@ -141,6 +140,19 @@ public class YifanHuLayout extends AbstractLayout implements Layout {
setConvergenceThreshold(1e-4f);
}
public float getAverageEdgeLength(Graph graph) {
float edgeLength = 0;
int count = 1;
for (Edge e : graph.getEdges()) {
edgeLength += ForceVectorUtils.distance(
e.getSource(), e.getTarget());
count++;
}
return edgeLength / count;
}
@Override
public LayoutProperty[] getProperties() {
List<LayoutProperty> properties = new ArrayList<LayoutProperty>();
final String YIFANHU_CATEGORY = "Yifan Hu's properties";
......@@ -148,14 +160,14 @@ public class YifanHuLayout extends AbstractLayout implements Layout {
try {
properties.add(LayoutProperty.createProperty(
this, Float.class,
this, Float.class,
NbBundle.getMessage(getClass(), "YifanHu.optimalDistance.name"),
YIFANHU_CATEGORY,
"YifanHu.optimalDistance.name",
NbBundle.getMessage(getClass(), "YifanHu.optimalDistance.desc"),
"getOptimalDistance", "setOptimalDistance"));
properties.add(LayoutProperty.createProperty(
this, Float.class,
this, Float.class,
NbBundle.getMessage(getClass(), "YifanHu.relativeStrength.name"),
YIFANHU_CATEGORY,
"YifanHu.relativeStrength.name",
......@@ -163,42 +175,42 @@ public class YifanHuLayout extends AbstractLayout implements Layout {
"getRelativeStrength", "setRelativeStrength"));
properties.add(LayoutProperty.createProperty(
this, Float.class,
this, Float.class,
NbBundle.getMessage(getClass(), "YifanHu.initialStepSize.name"),
YIFANHU_CATEGORY,
"YifanHu.initialStepSize.name",
NbBundle.getMessage(getClass(), "YifanHu.initialStepSize.desc"),
"getInitialStep", "setInitialStep"));
properties.add(LayoutProperty.createProperty(
this, Float.class,
this, Float.class,
NbBundle.getMessage(getClass(), "YifanHu.stepRatio.name"),
YIFANHU_CATEGORY,
"YifanHu.stepRatio.name",
NbBundle.getMessage(getClass(), "YifanHu.stepRatio.desc"),
"getStepRatio", "setStepRatio"));
properties.add(LayoutProperty.createProperty(
this, Boolean.class,
this, Boolean.class,
NbBundle.getMessage(getClass(), "YifanHu.adaptativeCooling.name"),
YIFANHU_CATEGORY,
"YifanHu.adaptativeCooling.name",
NbBundle.getMessage(getClass(), "YifanHu.adaptativeCooling.desc"),
"isAdaptiveCooling", "setAdaptiveCooling"));
properties.add(LayoutProperty.createProperty(
this, Float.class,
this, Float.class,
NbBundle.getMessage(getClass(), "YifanHu.convergenceThreshold.name"),
YIFANHU_CATEGORY,
"YifanHu.convergenceThreshold.name",
NbBundle.getMessage(getClass(), "YifanHu.convergenceThreshold.desc"),
"getConvergenceThreshold", "setConvergenceThreshold"));
properties.add(LayoutProperty.createProperty(
this, Integer.class,
this, Integer.class,
NbBundle.getMessage(getClass(), "YifanHu.quadTreeMaxLevel.name"),
BARNESHUT_CATEGORY,
"YifanHu.quadTreeMaxLevel.name",
NbBundle.getMessage(getClass(), "YifanHu.quadTreeMaxLevel.desc"),
"getQuadTreeMaxLevel", "setQuadTreeMaxLevel"));
properties.add(LayoutProperty.createProperty(
this, Float.class,
this, Float.class,
NbBundle.getMessage(getClass(), "YifanHu.theta.name"),
BARNESHUT_CATEGORY,
"YifanHu.theta.name",
......@@ -211,35 +223,36 @@ public class YifanHuLayout extends AbstractLayout implements Layout {
return properties.toArray(new LayoutProperty[0]);
}
@Override
public void initAlgo() {
if (graphModel == null) {
return;
}
graph = graphModel.getHierarchicalGraphVisible();
graph = graphModel.getGraph(graphModel.getVisibleView());
energy = Float.POSITIVE_INFINITY;
for (Node n : graph.getNodes()) {
NodeData data = n.getNodeData();
data.setLayoutData(new ForceVector());
n.setLayoutData(new ForceVector());
}
progress = 0;
setConverged(false);
setStep(initialStep);
}
@Override
public void endAlgo() {
for (Node node : graph.getNodes()) {
NodeData data = node.getNodeData();
data.setLayoutData(null);
for (Node n : graph.getNodes()) {
n.setLayoutData(null);
}
}
@Override
public void goAlgo() {
graph = graphModel.getHierarchicalGraphVisible();
graph = graphModel.getGraph(graphModel.getVisibleView());
graph.readLock();
Node[] nodes = graph.getNodes().toArray();
for (Node n : nodes) {
if (n.getNodeData().getLayoutData() == null || !(n.getNodeData().getLayoutData() instanceof ForceVector)) {
n.getNodeData().setLayoutData(new ForceVector());
if (n.getLayoutData() == null || !(n.getLayoutData() instanceof ForceVector)) {
n.setLayoutData(new ForceVector());
}
}
......@@ -251,20 +264,19 @@ public class YifanHuLayout extends AbstractLayout implements Layout {
BarnesHut barnes = new BarnesHut(getNodeForce());
barnes.setTheta(getBarnesHutTheta());
for (Node node : nodes) {
NodeData data = node.getNodeData();
ForceVector layoutData = data.getLayoutData();
ForceVector layoutData = node.getLayoutData();
ForceVector f = barnes.calculateForce(data, tree);
ForceVector f = barnes.calculateForce(node, tree);
layoutData.add(f);
// electricEnergy += f.getEnergy();
}
// Apply edge forces.
for (Edge e : graph.getEdgesAndMetaEdges()) {
for (Edge e : graph.getEdges()) {
if (!e.getSource().equals(e.getTarget())) {
NodeData n1 = e.getSource().getNodeData();
NodeData n2 = e.getTarget().getNodeData();
Node n1 = e.getSource();
Node n2 = e.getTarget();
ForceVector f1 = n1.getLayoutData();
ForceVector f2 = n2.getLayoutData();
......@@ -279,8 +291,7 @@ public class YifanHuLayout extends AbstractLayout implements Layout {
energy = 0;
double maxForce = 1;
for (Node n : nodes) {
NodeData data = n.getNodeData();
ForceVector force = data.getLayoutData();
ForceVector force = n.getLayoutData();
energy += force.getNorm();
maxForce = Math.max(maxForce, force.getNorm());
......@@ -288,12 +299,11 @@ public class YifanHuLayout extends AbstractLayout implements Layout {
// Apply displacements on nodes.
for (Node n : nodes) {
NodeData data = n.getNodeData();
if (!data.isFixed()) {
ForceVector force = data.getLayoutData();
if (!n.isFixed()) {
ForceVector force = n.getLayoutData();
force.multiply((float) (1.0 / maxForce));
getDisplacement().moveNode(data, force);
getDisplacement().moveNode(n, force);
}
}
postAlgo();
......@@ -415,6 +425,7 @@ public class YifanHuLayout extends AbstractLayout implements Layout {
/**
* Fa = (n2 - n1) * ||n2 - n1|| / K
*
* @author Helder Suzuki <heldersuzuki@gephi.org>
*/
public class SpringForce extends AbstractForce {
......@@ -426,7 +437,7 @@ public class YifanHuLayout extends AbstractLayout implements Layout {
}
@Override
public ForceVector calculateForce(Spatial node1, Spatial node2,
public ForceVector calculateForce(Node node1, Node node2,
float distance) {
ForceVector f = new ForceVector(node2.x() - node1.x(),
node2.y() - node1.y());
......@@ -445,6 +456,7 @@ public class YifanHuLayout extends AbstractLayout implements Layout {
/**
* Fr = -C*K*K*(n2-n1)/||n2-n1||
*
* @author Helder Suzuki <heldersuzuki@gephi.org>
*/
public class ElectricalForce extends AbstractForce {
......@@ -458,7 +470,7 @@ public class YifanHuLayout extends AbstractLayout implements Layout {
}
@Override
public ForceVector calculateForce(Spatial node1, Spatial node2,
public ForceVector calculateForce(Node node1, Node node2,
float distance) {
ForceVector f = new ForceVector(node2.x() - node1.x(),
node2.y() - node1.y());
......
/*
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.
*/
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.layout.plugin.force.yifanHu;
import javax.swing.Icon;
......@@ -59,37 +59,45 @@ public class YifanHuProportional implements LayoutBuilder {
private YifanHuProportionalLayoutUI ui = new YifanHuProportionalLayoutUI();
@Override
public YifanHuLayout buildLayout() {
YifanHuLayout layout = new YifanHuLayout(this, new ProportionalDisplacement(1f));
return layout;
}
@Override
public String getName() {
return NbBundle.getMessage(YifanHuProportional.class, "YifanHuProportional.name");
}
@Override
public LayoutUI getUI() {
return ui;
}
private static class YifanHuProportionalLayoutUI implements LayoutUI {
@Override
public String getDescription() {
return NbBundle.getMessage(YifanHuProportional.class, "YifanHuProportional.description");
}
@Override
public Icon getIcon() {
return null;
}
@Override
public JPanel getSimplePanel(Layout layout) {
return null;
}
@Override
public int getQualityRank() {
return 3;
}
@Override
public int getSpeedRank() {
return 4;
}
......
/*
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.layout.plugin.forceAtlas;
......@@ -58,36 +58,44 @@ public class ForceAtlas implements LayoutBuilder {
private ForceAtlasLayoutUI ui = new ForceAtlasLayoutUI();
@Override
public String getName() {
return NbBundle.getMessage(ForceAtlasLayout.class, "name");
}
@Override
public ForceAtlasLayout buildLayout() {
return new ForceAtlasLayout(this);
}
@Override
public LayoutUI getUI() {
return ui;
}
private static class ForceAtlasLayoutUI implements LayoutUI {
@Override
public String getDescription() {
return NbBundle.getMessage(ForceAtlas.class, "description");
}
@Override
public Icon getIcon() {
return null;
}
@Override
public JPanel getSimplePanel(Layout layout) {
return null;
}
@Override
public int getQualityRank() {
return 5;
}
@Override
public int getSpeedRank() {
return 3;
}
......
/*
Copyright 2008-2010 Gephi
Authors : Mathieu Jacomy
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.
*/
Copyright 2008-2010 Gephi
Authors : Mathieu Jacomy
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.layout.plugin.forceAtlas;
import java.util.ArrayList;
import java.util.List;
import org.gephi.data.attributes.type.TimeInterval;
import org.gephi.dynamic.DynamicUtilities;
import org.gephi.graph.api.Edge;
import org.gephi.graph.api.HierarchicalGraph;
import org.gephi.graph.api.Graph;
import org.gephi.graph.api.Node;
import org.gephi.graph.api.NodeData;
import org.gephi.layout.plugin.AbstractLayout;
import org.gephi.layout.plugin.ForceVectorUtils;
......@@ -65,7 +62,7 @@ import org.openide.util.NbBundle;
public class ForceAtlasLayout extends AbstractLayout implements Layout {
//Graph
protected HierarchicalGraph graph;
protected Graph graph;
//Properties
public double inertia;
private double repulsionStrength;
......@@ -79,13 +76,12 @@ public class ForceAtlasLayout extends AbstractLayout implements Layout {
private double cooling;
private boolean outboundAttractionDistribution;
private boolean adjustSizes;
//Dynamic Weight
private TimeInterval timeInterval;
public ForceAtlasLayout(LayoutBuilder layoutBuilder) {
super(layoutBuilder);
}
@Override
public void resetPropertiesValues() {
inertia = 0.1;
setRepulsionStrength(200d);
......@@ -101,25 +97,25 @@ public class ForceAtlasLayout extends AbstractLayout implements Layout {
setCooling(1d);
}
@Override
public void initAlgo() {
this.graph = graphModel.getHierarchicalGraphVisible();
}
@Override
public void goAlgo() {
this.graph = graphModel.getHierarchicalGraphVisible();
this.timeInterval = DynamicUtilities.getVisibleInterval(dynamicModel);
this.graph = graphModel.getGraph(graphModel.getVisibleView());
graph.readLock();
Node[] nodes = graph.getNodes().toArray();
Edge[] edges = graph.getEdgesAndMetaEdges().toArray();
Edge[] edges = graph.getEdges().toArray();
for (Node n : nodes) {
if (n.getNodeData().getLayoutData() == null || !(n.getNodeData().getLayoutData() instanceof ForceVectorNodeLayoutData)) {
n.getNodeData().setLayoutData(new ForceVectorNodeLayoutData());
if (n.getLayoutData() == null || !(n.getLayoutData() instanceof ForceVectorNodeLayoutData)) {
n.setLayoutData(new ForceVectorNodeLayoutData());
}
}
for (Node n : nodes) {
ForceVectorNodeLayoutData layoutData = n.getNodeData().getLayoutData();
ForceVectorNodeLayoutData layoutData = n.getLayoutData();
layoutData.old_dx = layoutData.dx;
layoutData.old_dy = layoutData.dy;
layoutData.dx *= inertia;
......@@ -130,7 +126,7 @@ public class ForceAtlasLayout extends AbstractLayout implements Layout {
for (Node n1 : nodes) {
for (Node n2 : nodes) {
if (n1 != n2) {
ForceVectorUtils.fcBiRepulsor_noCollide(n1.getNodeData(), n2.getNodeData(), getRepulsionStrength() * (1 + graph.getDegree(n1)) * (1 + graph.getDegree(n2)));
ForceVectorUtils.fcBiRepulsor_noCollide(n1, n2, getRepulsionStrength() * (1 + graph.getDegree(n1)) * (1 + graph.getDegree(n2)));
}
}
}
......@@ -138,7 +134,7 @@ public class ForceAtlasLayout extends AbstractLayout implements Layout {
for (Node n1 : nodes) {
for (Node n2 : nodes) {
if (n1 != n2) {
ForceVectorUtils.fcBiRepulsor(n1.getNodeData(), n2.getNodeData(), getRepulsionStrength() * (1 + graph.getDegree(n1)) * (1 + graph.getDegree(n2)));
ForceVectorUtils.fcBiRepulsor(n1, n2, getRepulsionStrength() * (1 + graph.getDegree(n1)) * (1 + graph.getDegree(n2)));
}
}
}
......@@ -149,17 +145,17 @@ public class ForceAtlasLayout extends AbstractLayout implements Layout {
for (Edge e : edges) {
Node nf = e.getSource();
Node nt = e.getTarget();
double bonus = (nf.getNodeData().isFixed() || nt.getNodeData().isFixed()) ? (100) : (1);
bonus *= getWeight(e);
ForceVectorUtils.fcBiAttractor_noCollide(nf.getNodeData(), nt.getNodeData(), bonus * getAttractionStrength() / (1 + graph.getDegree(nf)));
double bonus = (nf.isFixed() || nt.isFixed()) ? (100) : (1);
bonus *= e.getWeight();
ForceVectorUtils.fcBiAttractor_noCollide(nf, nt, bonus * getAttractionStrength() / (1 + graph.getDegree(nf)));
}
} else {
for (Edge e : edges) {
Node nf = e.getSource();
Node nt = e.getTarget();
double bonus = (nf.getNodeData().isFixed() || nt.getNodeData().isFixed()) ? (100) : (1);
bonus *= getWeight(e);
ForceVectorUtils.fcBiAttractor_noCollide(nf.getNodeData(), nt.getNodeData(), bonus * getAttractionStrength());
double bonus = (nf.isFixed() || nt.isFixed()) ? (100) : (1);
bonus *= e.getWeight();
ForceVectorUtils.fcBiAttractor_noCollide(nf, nt, bonus * getAttractionStrength());
}
}
} else {
......@@ -167,50 +163,49 @@ public class ForceAtlasLayout extends AbstractLayout implements Layout {
for (Edge e : edges) {
Node nf = e.getSource();
Node nt = e.getTarget();
double bonus = (nf.getNodeData().isFixed() || nt.getNodeData().isFixed()) ? (100) : (1);
bonus *= getWeight(e);
ForceVectorUtils.fcBiAttractor(nf.getNodeData(), nt.getNodeData(), bonus * getAttractionStrength() / (1 + graph.getDegree(nf)));
double bonus = (nf.isFixed() || nt.isFixed()) ? (100) : (1);
bonus *= e.getWeight();
ForceVectorUtils.fcBiAttractor(nf, nt, bonus * getAttractionStrength() / (1 + graph.getDegree(nf)));
}
} else {
for (Edge e : edges) {
Node nf = e.getSource();
Node nt = e.getTarget();
double bonus = (nf.getNodeData().isFixed() || nt.getNodeData().isFixed()) ? (100) : (1);
bonus *= getWeight(e);
ForceVectorUtils.fcBiAttractor(nf.getNodeData(), nt.getNodeData(), bonus * getAttractionStrength());
double bonus = (nf.isFixed() || nt.isFixed()) ? (100) : (1);
bonus *= e.getWeight();
ForceVectorUtils.fcBiAttractor(nf, nt, bonus * getAttractionStrength());
}
}
}
// gravity
for (Node n : nodes) {
float nx = n.getNodeData().x();
float ny = n.getNodeData().y();
float nx = n.x();
float ny = n.y();
double d = 0.0001 + Math.sqrt(nx * nx + ny * ny);
double gf = 0.0001 * getGravity() * d;
ForceVectorNodeLayoutData layoutData = n.getNodeData().getLayoutData();
ForceVectorNodeLayoutData layoutData = n.getLayoutData();
layoutData.dx -= gf * nx / d;
layoutData.dy -= gf * ny / d;
}
// speed
if (isFreezeBalance()) {
for (Node n : nodes) {
ForceVectorNodeLayoutData layoutData = n.getNodeData().getLayoutData();
ForceVectorNodeLayoutData layoutData = n.getLayoutData();
layoutData.dx *= getSpeed() * 10f;
layoutData.dy *= getSpeed() * 10f;
}
} else {
for (Node n : nodes) {
ForceVectorNodeLayoutData layoutData = n.getNodeData().getLayoutData();
ForceVectorNodeLayoutData layoutData = n.getLayoutData();
layoutData.dx *= getSpeed();
layoutData.dy *= getSpeed();
}
}
// apply forces
for (Node n : nodes) {
NodeData nData = n.getNodeData();
ForceVectorNodeLayoutData nLayout = nData.getLayoutData();
if (!nData.isFixed()) {
ForceVectorNodeLayoutData nLayout = n.getLayoutData();
if (!n.isFixed()) {
double d = 0.0001 + Math.sqrt(nLayout.dx * nLayout.dx + nLayout.dy * nLayout.dy);
float ratio;
if (isFreezeBalance()) {
......@@ -221,11 +216,11 @@ public class ForceAtlasLayout extends AbstractLayout implements Layout {
}
nLayout.dx *= ratio / getCooling();
nLayout.dy *= ratio / getCooling();
float x = nData.x() + nLayout.dx;
float y = nData.y() + nLayout.dy;
float x = n.x() + nLayout.dx;
float y = n.y() + nLayout.dy;
nData.setX(x);
nData.setY(y);
n.setX(x);
n.setY(y);
}
}
graph.readUnlock();
......@@ -233,7 +228,7 @@ public class ForceAtlasLayout extends AbstractLayout implements Layout {
public void endAlgo() {
for (Node n : graph.getNodes()) {
n.getNodeData().setLayoutData(null);
n.setLayoutData(null);
}
}
......@@ -242,14 +237,7 @@ public class ForceAtlasLayout extends AbstractLayout implements Layout {
return true;
}
private float getWeight(Edge edge) {
if(timeInterval!=null) {
return edge.getWeight(timeInterval.getLow(), timeInterval.getHigh());
} else {
return edge.getWeight();
}
}
@Override
public LayoutProperty[] getProperties() {
List<LayoutProperty> properties = new ArrayList<LayoutProperty>();
final String FORCE_ATLAS = "Force Atlas";
......@@ -481,7 +469,8 @@ public class ForceAtlasLayout extends AbstractLayout implements Layout {
}
/**
* @param outboundAttractionDistribution the outboundAttractionDistribution to set
* @param outboundAttractionDistribution the outboundAttractionDistribution
* to set
*/
public void setOutboundAttractionDistribution(Boolean outboundAttractionDistribution) {
this.outboundAttractionDistribution = outboundAttractionDistribution;
......
/*
Copyright 2008-2011 Gephi
Authors : Mathieu Jacomy <mathieu.jacomy@gmail.com>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2011 Gephi Consortium. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 3 only ("GPL") or the Common
Development and Distribution License("CDDL") (collectively, the
"License"). You may not use this file except in compliance with the
License. You can obtain a copy of the License at
http://gephi.org/about/legal/license-notice/
or /cddl-1.0.txt and /gpl-3.0.txt. See the License for the
specific language governing permissions and limitations under the
License. When distributing the software, include this License Header
Notice in each file and include the License files at
/cddl-1.0.txt and /gpl-3.0.txt. If applicable, add the following below the
License Header, with the fields enclosed by brackets [] replaced by
your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"
If you wish your version of this file to be governed by only the CDDL
or only the GPL Version 3, indicate your decision by adding
"[Contributor] elects to include this software in this distribution
under the [CDDL or GPL Version 3] license." If you do not indicate a
single choice of license, a recipient has the option to distribute
your version of this file under either the CDDL, the GPL Version 3 or
to extend the choice of license to its licensees as provided above.
However, if you add GPL Version 3 code and therefore, elected the GPL
Version 3 license, then the option applies only if the new code is
made subject to such option by the copyright holder.
Contributor(s):
Portions Copyrighted 2011 Gephi Consortium.
Copyright 2008-2011 Gephi
Authors : Mathieu Jacomy <mathieu.jacomy@gmail.com>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2011 Gephi Consortium. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 3 only ("GPL") or the Common
Development and Distribution License("CDDL") (collectively, the
"License"). You may not use this file except in compliance with the
License. You can obtain a copy of the License at
http://gephi.org/about/legal/license-notice/
or /cddl-1.0.txt and /gpl-3.0.txt. See the License for the
specific language governing permissions and limitations under the
License. When distributing the software, include this License Header
Notice in each file and include the License files at
/cddl-1.0.txt and /gpl-3.0.txt. If applicable, add the following below the
License Header, with the fields enclosed by brackets [] replaced by
your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"
If you wish your version of this file to be governed by only the CDDL
or only the GPL Version 3, indicate your decision by adding
"[Contributor] elects to include this software in this distribution
under the [CDDL or GPL Version 3] license." If you do not indicate a
single choice of license, a recipient has the option to distribute
your version of this file under either the CDDL, the GPL Version 3 or
to extend the choice of license to its licensees as provided above.
However, if you add GPL Version 3 code and therefore, elected the GPL
Version 3 license, then the option applies only if the new code is
made subject to such option by the copyright holder.
Contributor(s):
Portions Copyrighted 2011 Gephi Consortium.
*/
package org.gephi.layout.plugin.forceAtlas2;
......@@ -47,35 +47,28 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import org.gephi.data.attributes.type.TimeInterval;
import org.gephi.dynamic.DynamicUtilities;
import org.gephi.dynamic.api.DynamicController;
import org.gephi.dynamic.api.DynamicModel;
import org.gephi.graph.api.Edge;
import org.gephi.graph.api.Graph;
import org.gephi.graph.api.GraphModel;
import org.gephi.graph.api.HierarchicalGraph;
import org.gephi.graph.api.Node;
import org.gephi.graph.api.NodeData;
import org.gephi.layout.plugin.forceAtlas2.ForceFactory.AttractionForce;
import org.gephi.layout.plugin.forceAtlas2.ForceFactory.RepulsionForce;
import org.gephi.layout.spi.Layout;
import org.gephi.layout.spi.LayoutBuilder;
import org.gephi.layout.spi.LayoutProperty;
import org.gephi.project.api.Workspace;
import org.openide.util.Exceptions;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
/**
* ForceAtlas 2 Layout, manages each step of the computations.
*
* @author Mathieu Jacomy
*/
public class ForceAtlas2 implements Layout {
private GraphModel graphModel;
private HierarchicalGraph graph;
private Graph graph;
private final ForceAtlas2Builder layoutBuilder;
private DynamicModel dynamicModel;
private double edgeWeightInfluence;
private double jitterTolerance;
private double scalingRatio;
......@@ -91,8 +84,6 @@ public class ForceAtlas2 implements Layout {
private int currentThreadCount;
private Region rootRegion;
double outboundAttCompensation = 1;
//Dynamic Weight
private TimeInterval timeInterval;
private ExecutorService pool;
public ForceAtlas2(ForceAtlas2Builder layoutBuilder) {
......@@ -104,20 +95,18 @@ public class ForceAtlas2 implements Layout {
public void initAlgo() {
speed = 1.;
graph = graphModel.getHierarchicalGraphVisible();
this.timeInterval = DynamicUtilities.getVisibleInterval(dynamicModel);
graph = graphModel.getGraph(graphModel.getVisibleView());
graph.readLock();
Node[] nodes = graph.getNodes().toArray();
// Initialise layout data
for (Node n : nodes) {
if (n.getNodeData().getLayoutData() == null || !(n.getNodeData().getLayoutData() instanceof ForceAtlas2LayoutData)) {
if (n.getLayoutData() == null || !(n.getLayoutData() instanceof ForceAtlas2LayoutData)) {
ForceAtlas2LayoutData nLayout = new ForceAtlas2LayoutData();
n.getNodeData().setLayoutData(nLayout);
n.setLayoutData(nLayout);
}
NodeData nData = n.getNodeData();
ForceAtlas2LayoutData nLayout = nData.getLayoutData();
ForceAtlas2LayoutData nLayout = n.getLayoutData();
nLayout.mass = 1 + graph.getDegree(n);
nLayout.old_dx = 0;
nLayout.old_dy = 0;
......@@ -135,21 +124,19 @@ public class ForceAtlas2 implements Layout {
if (graphModel == null) {
return;
}
graph = graphModel.getHierarchicalGraphVisible();
this.timeInterval = DynamicUtilities.getVisibleInterval(dynamicModel);
graph = graphModel.getGraph(graphModel.getVisibleView());
graph.readLock();
Node[] nodes = graph.getNodes().toArray();
Edge[] edges = graph.getEdgesAndMetaEdges().toArray();
Edge[] edges = graph.getEdges().toArray();
// Initialise layout data
for (Node n : nodes) {
if (n.getNodeData().getLayoutData() == null || !(n.getNodeData().getLayoutData() instanceof ForceAtlas2LayoutData)) {
if (n.getLayoutData() == null || !(n.getLayoutData() instanceof ForceAtlas2LayoutData)) {
ForceAtlas2LayoutData nLayout = new ForceAtlas2LayoutData();
n.getNodeData().setLayoutData(nLayout);
n.setLayoutData(nLayout);
}
NodeData nData = n.getNodeData();
ForceAtlas2LayoutData nLayout = nData.getLayoutData();
ForceAtlas2LayoutData nLayout = n.getLayoutData();
nLayout.mass = 1 + graph.getDegree(n);
nLayout.old_dx = nLayout.dx;
nLayout.old_dy = nLayout.dy;
......@@ -167,8 +154,7 @@ public class ForceAtlas2 implements Layout {
if (isOutboundAttractionDistribution()) {
outboundAttCompensation = 0;
for (Node n : nodes) {
NodeData nData = n.getNodeData();
ForceAtlas2LayoutData nLayout = nData.getLayoutData();
ForceAtlas2LayoutData nLayout = n.getLayoutData();
outboundAttCompensation += nLayout.mass;
}
outboundAttCompensation /= nodes.length;
......@@ -205,11 +191,11 @@ public class ForceAtlas2 implements Layout {
}
} else if (getEdgeWeightInfluence() == 1) {
for (Edge e : edges) {
Attraction.apply(e.getSource(), e.getTarget(), getWeight(e));
Attraction.apply(e.getSource(), e.getTarget(), e.getWeight());
}
} else {
for (Edge e : edges) {
Attraction.apply(e.getSource(), e.getTarget(), Math.pow(getWeight(e), getEdgeWeightInfluence()));
Attraction.apply(e.getSource(), e.getTarget(), Math.pow(e.getWeight(), getEdgeWeightInfluence()));
}
}
......@@ -217,9 +203,8 @@ public class ForceAtlas2 implements Layout {
double totalSwinging = 0d; // How much irregular movement
double totalEffectiveTraction = 0d; // Hom much useful movement
for (Node n : nodes) {
NodeData nData = n.getNodeData();
ForceAtlas2LayoutData nLayout = nData.getLayoutData();
if (!nData.isFixed()) {
ForceAtlas2LayoutData nLayout = n.getLayoutData();
if (!n.isFixed()) {
double swinging = Math.sqrt(Math.pow(nLayout.old_dx - nLayout.dx, 2) + Math.pow(nLayout.old_dy - nLayout.dy, 2));
totalSwinging += nLayout.mass * swinging; // If the node has a burst change of direction, then it's not converging.
totalEffectiveTraction += nLayout.mass * 0.5 * Math.sqrt(Math.pow(nLayout.old_dx + nLayout.dx, 2) + Math.pow(nLayout.old_dy + nLayout.dy, 2));
......@@ -236,9 +221,8 @@ public class ForceAtlas2 implements Layout {
if (isAdjustSizes()) {
// If nodes overlap prevention is active, it's not possible to trust the swinging mesure.
for (Node n : nodes) {
NodeData nData = n.getNodeData();
ForceAtlas2LayoutData nLayout = nData.getLayoutData();
if (!nData.isFixed()) {
ForceAtlas2LayoutData nLayout = n.getLayoutData();
if (!n.isFixed()) {
// Adaptive auto-speed: the speed of each node is lowered
// when the node swings.
......@@ -248,18 +232,17 @@ public class ForceAtlas2 implements Layout {
double df = Math.sqrt(Math.pow(nLayout.dx, 2) + Math.pow(nLayout.dy, 2));
factor = Math.min(factor * df, 10.) / df;
double x = nData.x() + nLayout.dx * factor;
double y = nData.y() + nLayout.dy * factor;
double x = n.x() + nLayout.dx * factor;
double y = n.y() + nLayout.dy * factor;
nData.setX((float) x);
nData.setY((float) y);
n.setX((float) x);
n.setY((float) y);
}
}
} else {
for (Node n : nodes) {
NodeData nData = n.getNodeData();
ForceAtlas2LayoutData nLayout = nData.getLayoutData();
if (!nData.isFixed()) {
ForceAtlas2LayoutData nLayout = n.getLayoutData();
if (!n.isFixed()) {
// Adaptive auto-speed: the speed of each node is lowered
// when the node swings.
......@@ -267,11 +250,11 @@ public class ForceAtlas2 implements Layout {
//double factor = speed / (1f + Math.sqrt(speed * swinging));
double factor = speed / (1f + speed * Math.sqrt(swinging));
double x = nData.x() + nLayout.dx * factor;
double y = nData.y() + nLayout.dy * factor;
double x = n.x() + nLayout.dx * factor;
double y = n.y() + nLayout.dy * factor;
nData.setX((float) x);
nData.setY((float) y);
n.setX((float) x);
n.setY((float) y);
}
}
}
......@@ -286,7 +269,7 @@ public class ForceAtlas2 implements Layout {
@Override
public void endAlgo() {
for (Node n : graph.getNodes()) {
n.getNodeData().setLayoutData(null);
n.setLayoutData(null);
}
pool.shutdown();
graph.readUnlockAll();
......@@ -401,7 +384,7 @@ public class ForceAtlas2 implements Layout {
int nodesCount = 0;
if (graphModel != null) {
nodesCount = graphModel.getHierarchicalGraphVisible().getNodeCount();
nodesCount = graphModel.getGraph(graphModel.getVisibleView()).getNodeCount();
}
// Tuning
......@@ -444,11 +427,6 @@ public class ForceAtlas2 implements Layout {
@Override
public void setGraphModel(GraphModel graphModel) {
this.graphModel = graphModel;
Workspace workspace = graphModel.getWorkspace();
DynamicController dynamicController = Lookup.getDefault().lookup(DynamicController.class);
if (dynamicController != null && workspace != null) {
dynamicModel = dynamicController.getModel(workspace);
}
// Trick: reset here to take the profile of the graph in account for default values
resetPropertiesValues();
}
......@@ -544,12 +522,4 @@ public class ForceAtlas2 implements Layout {
public void setBarnesHutOptimize(Boolean barnesHutOptimize) {
this.barnesHutOptimize = barnesHutOptimize;
}
private float getWeight(Edge edge) {
if (timeInterval != null) {
return edge.getWeight(timeInterval.getLow(), timeInterval.getHigh());
} else {
return edge.getWeight();
}
}
}
/*
Copyright 2008-2011 Gephi
Authors : Mathieu Jacomy <mathieu.jacomy@gmail.com>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2011 Gephi Consortium. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 3 only ("GPL") or the Common
Development and Distribution License("CDDL") (collectively, the
"License"). You may not use this file except in compliance with the
License. You can obtain a copy of the License at
http://gephi.org/about/legal/license-notice/
or /cddl-1.0.txt and /gpl-3.0.txt. See the License for the
specific language governing permissions and limitations under the
License. When distributing the software, include this License Header
Notice in each file and include the License files at
/cddl-1.0.txt and /gpl-3.0.txt. If applicable, add the following below the
License Header, with the fields enclosed by brackets [] replaced by
your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"
If you wish your version of this file to be governed by only the CDDL
or only the GPL Version 3, indicate your decision by adding
"[Contributor] elects to include this software in this distribution
under the [CDDL or GPL Version 3] license." If you do not indicate a
single choice of license, a recipient has the option to distribute
your version of this file under either the CDDL, the GPL Version 3 or
to extend the choice of license to its licensees as provided above.
However, if you add GPL Version 3 code and therefore, elected the GPL
Version 3 license, then the option applies only if the new code is
made subject to such option by the copyright holder.
Contributor(s):
Portions Copyrighted 2011 Gephi Consortium.
Copyright 2008-2011 Gephi
Authors : Mathieu Jacomy <mathieu.jacomy@gmail.com>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2011 Gephi Consortium. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 3 only ("GPL") or the Common
Development and Distribution License("CDDL") (collectively, the
"License"). You may not use this file except in compliance with the
License. You can obtain a copy of the License at
http://gephi.org/about/legal/license-notice/
or /cddl-1.0.txt and /gpl-3.0.txt. See the License for the
specific language governing permissions and limitations under the
License. When distributing the software, include this License Header
Notice in each file and include the License files at
/cddl-1.0.txt and /gpl-3.0.txt. If applicable, add the following below the
License Header, with the fields enclosed by brackets [] replaced by
your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"
If you wish your version of this file to be governed by only the CDDL
or only the GPL Version 3, indicate your decision by adding
"[Contributor] elects to include this software in this distribution
under the [CDDL or GPL Version 3] license." If you do not indicate a
single choice of license, a recipient has the option to distribute
your version of this file under either the CDDL, the GPL Version 3 or
to extend the choice of license to its licensees as provided above.
However, if you add GPL Version 3 code and therefore, elected the GPL
Version 3 license, then the option applies only if the new code is
made subject to such option by the copyright holder.
Contributor(s):
Portions Copyrighted 2011 Gephi Consortium.
*/
package org.gephi.layout.plugin.forceAtlas2;
import org.gephi.graph.api.Node;
import org.gephi.graph.api.NodeData;
/**
* Generates the forces on demand, here are all the formulas for attraction and repulsion.
* Generates the forces on demand, here are all the formulas for attraction and
* repulsion.
*
* @author Mathieu Jacomy
*/
public class ForceFactory {
......@@ -128,14 +129,12 @@ public class ForceFactory {
@Override
public void apply(Node n1, Node n2) {
NodeData n1Data = n1.getNodeData();
ForceAtlas2LayoutData n1Layout = n1Data.getLayoutData();
NodeData n2Data = n2.getNodeData();
ForceAtlas2LayoutData n2Layout = n2Data.getLayoutData();
ForceAtlas2LayoutData n1Layout = n1.getLayoutData();
ForceAtlas2LayoutData n2Layout = n2.getLayoutData();
// Get the distance
double xDist = n1Data.x() - n2Data.x();
double yDist = n1Data.y() - n2Data.y();
double xDist = n1.x() - n2.x();
double yDist = n1.y() - n2.y();
double distance = (float) Math.sqrt(xDist * xDist + yDist * yDist);
if (distance > 0) {
......@@ -152,12 +151,11 @@ public class ForceFactory {
@Override
public void apply(Node n, Region r) {
NodeData nData = n.getNodeData();
ForceAtlas2LayoutData nLayout = nData.getLayoutData();
ForceAtlas2LayoutData nLayout = n.getLayoutData();
// Get the distance
double xDist = nData.x() - r.getMassCenterX();
double yDist = nData.y() - r.getMassCenterY();
double xDist = n.x() - r.getMassCenterX();
double yDist = n.y() - r.getMassCenterY();
double distance = (float) Math.sqrt(xDist * xDist + yDist * yDist);
if (distance > 0) {
......@@ -171,12 +169,11 @@ public class ForceFactory {
@Override
public void apply(Node n, double g) {
NodeData nData = n.getNodeData();
ForceAtlas2LayoutData nLayout = nData.getLayoutData();
ForceAtlas2LayoutData nLayout = n.getLayoutData();
// Get the distance
double xDist = nData.x();
double yDist = nData.y();
double xDist = n.x();
double yDist = n.y();
double distance = (float) Math.sqrt(xDist * xDist + yDist * yDist);
if (distance > 0) {
......@@ -202,15 +199,13 @@ public class ForceFactory {
@Override
public void apply(Node n1, Node n2) {
NodeData n1Data = n1.getNodeData();
ForceAtlas2LayoutData n1Layout = n1Data.getLayoutData();
NodeData n2Data = n2.getNodeData();
ForceAtlas2LayoutData n2Layout = n2Data.getLayoutData();
ForceAtlas2LayoutData n1Layout = n1.getLayoutData();
ForceAtlas2LayoutData n2Layout = n2.getLayoutData();
// Get the distance
double xDist = n1Data.x() - n2Data.x();
double yDist = n1Data.y() - n2Data.y();
double distance = Math.sqrt(xDist * xDist + yDist * yDist) - n1Data.getSize() - n2Data.getSize();
double xDist = n1.x() - n2.x();
double yDist = n1.y() - n2.y();
double distance = Math.sqrt(xDist * xDist + yDist * yDist) - n1.size() - n2.size();
if (distance > 0) {
// NB: factor = force / distance
......@@ -235,12 +230,11 @@ public class ForceFactory {
@Override
public void apply(Node n, Region r) {
NodeData nData = n.getNodeData();
ForceAtlas2LayoutData nLayout = nData.getLayoutData();
ForceAtlas2LayoutData nLayout = n.getLayoutData();
// Get the distance
double xDist = nData.x() - r.getMassCenterX();
double yDist = nData.y() - r.getMassCenterY();
double xDist = n.x() - r.getMassCenterX();
double yDist = n.y() - r.getMassCenterY();
double distance = (float) Math.sqrt(xDist * xDist + yDist * yDist);
if (distance > 0) {
......@@ -259,12 +253,11 @@ public class ForceFactory {
@Override
public void apply(Node n, double g) {
NodeData nData = n.getNodeData();
ForceAtlas2LayoutData nLayout = nData.getLayoutData();
ForceAtlas2LayoutData nLayout = n.getLayoutData();
// Get the distance
double xDist = nData.x();
double yDist = nData.y();
double xDist = n.x();
double yDist = n.y();
double distance = (float) Math.sqrt(xDist * xDist + yDist * yDist);
if (distance > 0) {
......@@ -297,12 +290,11 @@ public class ForceFactory {
@Override
public void apply(Node n, double g) {
NodeData nData = n.getNodeData();
ForceAtlas2LayoutData nLayout = nData.getLayoutData();
ForceAtlas2LayoutData nLayout = n.getLayoutData();
// Get the distance
double xDist = nData.x();
double yDist = nData.y();
double xDist = n.x();
double yDist = n.y();
double distance = (float) Math.sqrt(xDist * xDist + yDist * yDist);
if (distance > 0) {
......@@ -328,14 +320,12 @@ public class ForceFactory {
@Override
public void apply(Node n1, Node n2, double e) {
NodeData n1Data = n1.getNodeData();
ForceAtlas2LayoutData n1Layout = n1Data.getLayoutData();
NodeData n2Data = n2.getNodeData();
ForceAtlas2LayoutData n2Layout = n2Data.getLayoutData();
ForceAtlas2LayoutData n1Layout = n1.getLayoutData();
ForceAtlas2LayoutData n2Layout = n2.getLayoutData();
// Get the distance
double xDist = n1Data.x() - n2Data.x();
double yDist = n1Data.y() - n2Data.y();
double xDist = n1.x() - n2.x();
double yDist = n1.y() - n2.y();
// NB: factor = force / distance
double factor = -coefficient * e;
......@@ -361,14 +351,12 @@ public class ForceFactory {
@Override
public void apply(Node n1, Node n2, double e) {
NodeData n1Data = n1.getNodeData();
ForceAtlas2LayoutData n1Layout = n1Data.getLayoutData();
NodeData n2Data = n2.getNodeData();
ForceAtlas2LayoutData n2Layout = n2Data.getLayoutData();
ForceAtlas2LayoutData n1Layout = n1.getLayoutData();
ForceAtlas2LayoutData n2Layout = n2.getLayoutData();
// Get the distance
double xDist = n1Data.x() - n2Data.x();
double yDist = n1Data.y() - n2Data.y();
double xDist = n1.x() - n2.x();
double yDist = n1.y() - n2.y();
// NB: factor = force / distance
double factor = -coefficient * e / n1Layout.mass;
......@@ -394,14 +382,12 @@ public class ForceFactory {
@Override
public void apply(Node n1, Node n2, double e) {
NodeData n1Data = n1.getNodeData();
ForceAtlas2LayoutData n1Layout = n1Data.getLayoutData();
NodeData n2Data = n2.getNodeData();
ForceAtlas2LayoutData n2Layout = n2Data.getLayoutData();
ForceAtlas2LayoutData n1Layout = n1.getLayoutData();
ForceAtlas2LayoutData n2Layout = n2.getLayoutData();
// Get the distance
double xDist = n1Data.x() - n2Data.x();
double yDist = n1Data.y() - n2Data.y();
double xDist = n1.x() - n2.x();
double yDist = n1.y() - n2.y();
double distance = (float) Math.sqrt(xDist * xDist + yDist * yDist);
if (distance > 0) {
......@@ -431,14 +417,12 @@ public class ForceFactory {
@Override
public void apply(Node n1, Node n2, double e) {
NodeData n1Data = n1.getNodeData();
ForceAtlas2LayoutData n1Layout = n1Data.getLayoutData();
NodeData n2Data = n2.getNodeData();
ForceAtlas2LayoutData n2Layout = n2Data.getLayoutData();
ForceAtlas2LayoutData n1Layout = n1.getLayoutData();
ForceAtlas2LayoutData n2Layout = n2.getLayoutData();
// Get the distance
double xDist = n1Data.x() - n2Data.x();
double yDist = n1Data.y() - n2Data.y();
double xDist = n1.x() - n2.x();
double yDist = n1.y() - n2.y();
double distance = (float) Math.sqrt(xDist * xDist + yDist * yDist);
if (distance > 0) {
......@@ -468,15 +452,13 @@ public class ForceFactory {
@Override
public void apply(Node n1, Node n2, double e) {
NodeData n1Data = n1.getNodeData();
ForceAtlas2LayoutData n1Layout = n1Data.getLayoutData();
NodeData n2Data = n2.getNodeData();
ForceAtlas2LayoutData n2Layout = n2Data.getLayoutData();
ForceAtlas2LayoutData n1Layout = n1.getLayoutData();
ForceAtlas2LayoutData n2Layout = n2.getLayoutData();
// Get the distance
double xDist = n1Data.x() - n2Data.x();
double yDist = n1Data.y() - n2Data.y();
double distance = Math.sqrt(xDist * xDist + yDist * yDist) - n1Data.getSize() - n2Data.getSize();
double xDist = n1.x() - n2.x();
double yDist = n1.y() - n2.y();
double distance = Math.sqrt(xDist * xDist + yDist * yDist) - n1.size() - n2.size();
if (distance > 0) {
// NB: factor = force / distance
......@@ -504,15 +486,13 @@ public class ForceFactory {
@Override
public void apply(Node n1, Node n2, double e) {
NodeData n1Data = n1.getNodeData();
ForceAtlas2LayoutData n1Layout = n1Data.getLayoutData();
NodeData n2Data = n2.getNodeData();
ForceAtlas2LayoutData n2Layout = n2Data.getLayoutData();
ForceAtlas2LayoutData n1Layout = n1.getLayoutData();
ForceAtlas2LayoutData n2Layout = n2.getLayoutData();
// Get the distance
double xDist = n1Data.x() - n2Data.x();
double yDist = n1Data.y() - n2Data.y();
double distance = Math.sqrt(xDist * xDist + yDist * yDist) - n1Data.getSize() - n2Data.getSize();
double xDist = n1.x() - n2.x();
double yDist = n1.y() - n2.y();
double distance = Math.sqrt(xDist * xDist + yDist * yDist) - n1.size() - n2.size();
if (distance > 0) {
// NB: factor = force / distance
......@@ -540,15 +520,13 @@ public class ForceFactory {
@Override
public void apply(Node n1, Node n2, double e) {
NodeData n1Data = n1.getNodeData();
ForceAtlas2LayoutData n1Layout = n1Data.getLayoutData();
NodeData n2Data = n2.getNodeData();
ForceAtlas2LayoutData n2Layout = n2Data.getLayoutData();
ForceAtlas2LayoutData n1Layout = n1.getLayoutData();
ForceAtlas2LayoutData n2Layout = n2.getLayoutData();
// Get the distance
double xDist = n1Data.x() - n2Data.x();
double yDist = n1Data.y() - n2Data.y();
double distance = Math.sqrt(xDist * xDist + yDist * yDist) - n1Data.getSize() - n2Data.getSize();
double xDist = n1.x() - n2.x();
double yDist = n1.y() - n2.y();
double distance = Math.sqrt(xDist * xDist + yDist * yDist) - n1.size() - n2.size();
if (distance > 0) {
......@@ -577,15 +555,13 @@ public class ForceFactory {
@Override
public void apply(Node n1, Node n2, double e) {
NodeData n1Data = n1.getNodeData();
ForceAtlas2LayoutData n1Layout = n1Data.getLayoutData();
NodeData n2Data = n2.getNodeData();
ForceAtlas2LayoutData n2Layout = n2Data.getLayoutData();
ForceAtlas2LayoutData n1Layout = n1.getLayoutData();
ForceAtlas2LayoutData n2Layout = n2.getLayoutData();
// Get the distance
double xDist = n1Data.x() - n2Data.x();
double yDist = n1Data.y() - n2Data.y();
double distance = Math.sqrt(xDist * xDist + yDist * yDist) - n1Data.getSize() - n2Data.getSize();
double xDist = n1.x() - n2.x();
double yDist = n1.y() - n2.y();
double distance = Math.sqrt(xDist * xDist + yDist * yDist) - n1.size() - n2.size();
if (distance > 0) {
......
/*
Copyright 2008-2011 Gephi
Authors : Mathieu Jacomy <mathieu.jacomy@gmail.com>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2011 Gephi Consortium. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 3 only ("GPL") or the Common
Development and Distribution License("CDDL") (collectively, the
"License"). You may not use this file except in compliance with the
License. You can obtain a copy of the License at
http://gephi.org/about/legal/license-notice/
or /cddl-1.0.txt and /gpl-3.0.txt. See the License for the
specific language governing permissions and limitations under the
License. When distributing the software, include this License Header
Notice in each file and include the License files at
/cddl-1.0.txt and /gpl-3.0.txt. If applicable, add the following below the
License Header, with the fields enclosed by brackets [] replaced by
your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"
If you wish your version of this file to be governed by only the CDDL
or only the GPL Version 3, indicate your decision by adding
"[Contributor] elects to include this software in this distribution
under the [CDDL or GPL Version 3] license." If you do not indicate a
single choice of license, a recipient has the option to distribute
your version of this file under either the CDDL, the GPL Version 3 or
to extend the choice of license to its licensees as provided above.
However, if you add GPL Version 3 code and therefore, elected the GPL
Version 3 license, then the option applies only if the new code is
made subject to such option by the copyright holder.
Contributor(s):
Portions Copyrighted 2011 Gephi Consortium.
Copyright 2008-2011 Gephi
Authors : Mathieu Jacomy <mathieu.jacomy@gmail.com>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2011 Gephi Consortium. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 3 only ("GPL") or the Common
Development and Distribution License("CDDL") (collectively, the
"License"). You may not use this file except in compliance with the
License. You can obtain a copy of the License at
http://gephi.org/about/legal/license-notice/
or /cddl-1.0.txt and /gpl-3.0.txt. See the License for the
specific language governing permissions and limitations under the
License. When distributing the software, include this License Header
Notice in each file and include the License files at
/cddl-1.0.txt and /gpl-3.0.txt. If applicable, add the following below the
License Header, with the fields enclosed by brackets [] replaced by
your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"
If you wish your version of this file to be governed by only the CDDL
or only the GPL Version 3, indicate your decision by adding
"[Contributor] elects to include this software in this distribution
under the [CDDL or GPL Version 3] license." If you do not indicate a
single choice of license, a recipient has the option to distribute
your version of this file under either the CDDL, the GPL Version 3 or
to extend the choice of license to its licensees as provided above.
However, if you add GPL Version 3 code and therefore, elected the GPL
Version 3 license, then the option applies only if the new code is
made subject to such option by the copyright holder.
Contributor(s):
Portions Copyrighted 2011 Gephi Consortium.
*/
package org.gephi.layout.plugin.forceAtlas2;
......@@ -45,11 +45,11 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.gephi.graph.api.Node;
import org.gephi.graph.api.NodeData;
import org.gephi.layout.plugin.forceAtlas2.ForceFactory.RepulsionForce;
/**
* Barnes Hut optimization
*
* @author Mathieu Jacomy
*/
public class Region {
......@@ -79,11 +79,10 @@ public class Region {
double massSumX = 0;
double massSumY = 0;
for (Node n : nodes) {
NodeData nData = n.getNodeData();
ForceAtlas2LayoutData nLayout = nData.getLayoutData();
ForceAtlas2LayoutData nLayout = n.getLayoutData();
mass += nLayout.mass;
massSumX += nData.x() * nLayout.mass;
massSumY += nData.y() * nLayout.mass;
massSumX += n.x() * nLayout.mass;
massSumY += n.y() * nLayout.mass;
}
massCenterX = massSumX / mass;
massCenterY = massSumY / mass;
......@@ -91,8 +90,7 @@ public class Region {
// Compute size
size = Double.MIN_VALUE;
for (Node n : nodes) {
NodeData nData = n.getNodeData();
double distance = Math.sqrt((nData.x() - massCenterX) * (nData.x() - massCenterX) + (nData.y() - massCenterY) * (nData.y() - massCenterY));
double distance = Math.sqrt((n.x() - massCenterX) * (n.x() - massCenterX) + (n.y() - massCenterY) * (n.y() - massCenterY));
size = Math.max(size, 2 * distance);
}
}
......@@ -103,24 +101,21 @@ public class Region {
ArrayList<Node> leftNodes = new ArrayList<Node>();
ArrayList<Node> rightNodes = new ArrayList<Node>();
for (Node n : nodes) {
NodeData nData = n.getNodeData();
ArrayList<Node> nodesColumn = (nData.x() < massCenterX) ? (leftNodes) : (rightNodes);
ArrayList<Node> nodesColumn = (n.x() < massCenterX) ? (leftNodes) : (rightNodes);
nodesColumn.add(n);
}
ArrayList<Node> topleftNodes = new ArrayList<Node>();
ArrayList<Node> bottomleftNodes = new ArrayList<Node>();
for (Node n : leftNodes) {
NodeData nData = n.getNodeData();
ArrayList<Node> nodesLine = (nData.y() < massCenterY) ? (topleftNodes) : (bottomleftNodes);
ArrayList<Node> nodesLine = (n.y() < massCenterY) ? (topleftNodes) : (bottomleftNodes);
nodesLine.add(n);
}
ArrayList<Node> bottomrightNodes = new ArrayList<Node>();
ArrayList<Node> toprightNodes = new ArrayList<Node>();
for (Node n : rightNodes) {
NodeData nData = n.getNodeData();
ArrayList<Node> nodesLine = (nData.y() < massCenterY) ? (toprightNodes) : (bottomrightNodes);
ArrayList<Node> nodesLine = (n.y() < massCenterY) ? (toprightNodes) : (bottomrightNodes);
nodesLine.add(n);
}
......@@ -184,12 +179,11 @@ public class Region {
}
public void applyForce(Node n, RepulsionForce Force, double theta) {
NodeData nData = n.getNodeData();
if (nodes.size() < 2) {
Node regionNode = nodes.get(0);
Force.apply(n, regionNode);
} else {
double distance = Math.sqrt((nData.x() - massCenterX) * (nData.x() - massCenterX) + (nData.y() - massCenterY) * (nData.y() - massCenterY));
double distance = Math.sqrt((n.x() - massCenterX) * (n.x() - massCenterX) + (n.y() - massCenterY) * (n.y() - massCenterY));
if (distance * theta > size) {
Force.apply(n, this);
} else {
......
/*
Copyright 2008-2010 Gephi
Authors : Mathieu Jacomy
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.
*/
Copyright 2008-2010 Gephi
Authors : Mathieu Jacomy
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.layout.plugin.fruchterman;
import java.util.ArrayList;
import java.util.List;
import org.gephi.graph.api.Edge;
import org.gephi.graph.api.Graph;
import org.gephi.graph.api.HierarchicalGraph;
import org.gephi.graph.api.Node;
import org.gephi.graph.api.NodeData;
import org.gephi.layout.plugin.AbstractLayout;
import org.gephi.layout.plugin.ForceVectorNodeLayoutData;
import org.gephi.layout.spi.Layout;
......@@ -64,7 +62,7 @@ public class FruchtermanReingold extends AbstractLayout implements Layout {
private static final float SPEED_DIVISOR = 800;
private static final float AREA_MULTIPLICATOR = 10000;
//Graph
protected HierarchicalGraph graph;
protected Graph graph;
//Properties
private float area;
private double gravity;
......@@ -74,30 +72,29 @@ public class FruchtermanReingold extends AbstractLayout implements Layout {
super(layoutBuilder);
}
@Override
public void resetPropertiesValues() {
speed = 1;
area = 10000;
gravity = 10;
}
@Override
public void initAlgo() {
this.graph = graphModel.getHierarchicalGraphVisible();
for (Node n : graph.getNodes()) {
n.getNodeData().setLayoutData(new ForceVectorNodeLayoutData());
}
}
@Override
public void goAlgo() {
this.graph = graphModel.getHierarchicalGraphVisible();
this.graph = graphModel.getGraph(graphModel.getVisibleView());
graph.readLock();
Node[] nodes = graph.getNodes().toArray();
Edge[] edges = graph.getEdgesAndMetaEdges().toArray();
Edge[] edges = graph.getEdges().toArray();
for (Node n : nodes) {
if (n.getNodeData().getLayoutData() == null || !(n.getNodeData().getLayoutData() instanceof ForceVectorNodeLayoutData)) {
n.getNodeData().setLayoutData(new ForceVectorNodeLayoutData());
if (n.getLayoutData() == null || !(n.getLayoutData() instanceof ForceVectorNodeLayoutData)) {
n.setLayoutData(new ForceVectorNodeLayoutData());
}
ForceVectorNodeLayoutData layoutData = n.getNodeData().getLayoutData();
ForceVectorNodeLayoutData layoutData = n.getLayoutData();
layoutData.dx = 0;
layoutData.dy = 0;
}
......@@ -108,13 +105,13 @@ public class FruchtermanReingold extends AbstractLayout implements Layout {
for (Node N1 : nodes) {
for (Node N2 : nodes) { // On fait toutes les paires de noeuds
if (N1 != N2) {
float xDist = N1.getNodeData().x() - N2.getNodeData().x(); // distance en x entre les deux noeuds
float yDist = N1.getNodeData().y() - N2.getNodeData().y();
float xDist = N1.x() - N2.x(); // distance en x entre les deux noeuds
float yDist = N1.y() - N2.y();
float dist = (float) Math.sqrt(xDist * xDist + yDist * yDist); // distance tout court
if (dist > 0) {
float repulsiveF = k * k / dist; // Force de répulsion
ForceVectorNodeLayoutData layoutData = N1.getNodeData().getLayoutData();
ForceVectorNodeLayoutData layoutData = N1.getLayoutData();
layoutData.dx += xDist / dist * repulsiveF; // on l'applique...
layoutData.dy += yDist / dist * repulsiveF;
}
......@@ -127,15 +124,15 @@ public class FruchtermanReingold extends AbstractLayout implements Layout {
Node Nf = E.getSource();
Node Nt = E.getTarget();
float xDist = Nf.getNodeData().x() - Nt.getNodeData().x();
float yDist = Nf.getNodeData().y() - Nt.getNodeData().y();
float xDist = Nf.x() - Nt.x();
float yDist = Nf.y() - Nt.y();
float dist = (float) Math.sqrt(xDist * xDist + yDist * yDist);
float attractiveF = dist * dist / k;
if (dist > 0) {
ForceVectorNodeLayoutData sourceLayoutData = Nf.getNodeData().getLayoutData();
ForceVectorNodeLayoutData targetLayoutData = Nt.getNodeData().getLayoutData();
ForceVectorNodeLayoutData sourceLayoutData = Nf.getLayoutData();
ForceVectorNodeLayoutData targetLayoutData = Nt.getLayoutData();
sourceLayoutData.dx -= xDist / dist * attractiveF;
sourceLayoutData.dy -= yDist / dist * attractiveF;
targetLayoutData.dx += xDist / dist * attractiveF;
......@@ -144,30 +141,29 @@ public class FruchtermanReingold extends AbstractLayout implements Layout {
}
// gravity
for (Node n : nodes) {
NodeData nodeData = n.getNodeData();
ForceVectorNodeLayoutData layoutData = nodeData.getLayoutData();
float d = (float) Math.sqrt(nodeData.x() * nodeData.x() + nodeData.y() * nodeData.y());
ForceVectorNodeLayoutData layoutData = n.getLayoutData();
float d = (float) Math.sqrt(n.x() * n.x() + n.y() * n.y());
float gf = 0.01f * k * (float) gravity * d;
layoutData.dx -= gf * nodeData.x() / d;
layoutData.dy -= gf * nodeData.y() / d;
layoutData.dx -= gf * n.x() / d;
layoutData.dy -= gf * n.y() / d;
}
// speed
for (Node n : nodes) {
ForceVectorNodeLayoutData layoutData = n.getNodeData().getLayoutData();
ForceVectorNodeLayoutData layoutData = n.getLayoutData();
layoutData.dx *= speed / SPEED_DIVISOR;
layoutData.dy *= speed / SPEED_DIVISOR;
}
for (Node n : nodes) {
// Maintenant on applique le déplacement calculé sur les noeuds.
// nb : le déplacement à chaque passe "instantanné" correspond à la force : c'est une sorte d'accélération.
ForceVectorNodeLayoutData layoutData = n.getNodeData().getLayoutData();
ForceVectorNodeLayoutData layoutData = n.getLayoutData();
float xDist = layoutData.dx;
float yDist = layoutData.dy;
float dist = (float) Math.sqrt(layoutData.dx * layoutData.dx + layoutData.dy * layoutData.dy);
if (dist > 0 && !n.getNodeData().isFixed()) {
if (dist > 0 && !n.isFixed()) {
float limitedDist = Math.min(maxDisplace * ((float) speed / SPEED_DIVISOR), dist);
n.getNodeData().setX(n.getNodeData().x() + xDist / dist * limitedDist);
n.getNodeData().setY(n.getNodeData().y() + yDist / dist * limitedDist);
n.setX(n.x() + xDist / dist * limitedDist);
n.setY(n.y() + yDist / dist * limitedDist);
}
}
graph.readUnlock();
......@@ -175,7 +171,7 @@ public class FruchtermanReingold extends AbstractLayout implements Layout {
public void endAlgo() {
for (Node n : graph.getNodes()) {
n.getNodeData().setLayoutData(null);
n.setLayoutData(null);
}
}
......
/*
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.
*/
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.layout.plugin.fruchterman;
import javax.swing.Icon;
import javax.swing.JPanel;
import org.gephi.layout.plugin.forceAtlas.ForceAtlas;
import org.gephi.layout.plugin.forceAtlas.ForceAtlasLayout;
import org.gephi.layout.spi.Layout;
import org.gephi.layout.spi.LayoutBuilder;
import org.gephi.layout.spi.LayoutUI;
......@@ -60,36 +58,44 @@ public class FruchtermanReingoldBuilder implements LayoutBuilder {
private FruchtermanReingoldLayoutUI ui = new FruchtermanReingoldLayoutUI();
@Override
public String getName() {
return NbBundle.getMessage(FruchtermanReingoldBuilder.class, "name");
}
@Override
public FruchtermanReingold buildLayout() {
return new FruchtermanReingold(this);
}
@Override
public LayoutUI getUI() {
return ui;
}
private static class FruchtermanReingoldLayoutUI implements LayoutUI {
@Override
public String getDescription() {
return NbBundle.getMessage(FruchtermanReingold.class, "description");
}
@Override
public Icon getIcon() {
return null;
}
@Override
public JPanel getSimplePanel(Layout layout) {
return null;
}
@Override
public int getQualityRank() {
return 2;
}
@Override
public int getSpeedRank() {
return 3;
}
......
/*
Copyright 2008-2010 Gephi
Authors : Mathieu Jacomy
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.
Copyright 2008-2010 Gephi
Authors : Mathieu Jacomy
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.layout.plugin.labelAdjust;
......@@ -73,27 +73,30 @@ public class LabelAdjust extends AbstractLayout implements Layout {
super(layoutBuilder);
}
@Override
public void resetPropertiesValues() {
speed = 1;
radiusScale = 1.1f;
adjustBySize = true;
}
@Override
public void initAlgo() {
setConverged(false);
}
@Override
public void goAlgo() {
this.graph = graphModel.getGraphVisible();
this.graph = graphModel.getGraph(graphModel.getVisibleView());
graph.readLock();
Node[] nodes = graph.getNodes().toArray();
//Reset Layout Data
for (Node n : nodes) {
if (n.getNodeData().getLayoutData() == null || !(n.getNodeData().getLayoutData() instanceof LabelAdjustLayoutData)) {
n.getNodeData().setLayoutData(new LabelAdjustLayoutData());
if (n.getLayoutData() == null || !(n.getLayoutData() instanceof LabelAdjustLayoutData)) {
n.setLayoutData(new LabelAdjustLayoutData());
}
LabelAdjustLayoutData layoutData = n.getNodeData().getLayoutData();
LabelAdjustLayoutData layoutData = n.getLayoutData();
layoutData.freeze = 0;
layoutData.dx = 0;
layoutData.dy = 0;
......@@ -107,11 +110,11 @@ public class LabelAdjust extends AbstractLayout implements Layout {
List<Node> correctNodes = new ArrayList<Node>();
for (Node n : nodes) {
float x = n.getNodeData().x();
float y = n.getNodeData().y();
float w = n.getNodeData().getTextData().getWidth();
float h = n.getNodeData().getTextData().getHeight();
float radius = n.getNodeData().getRadius();
float x = n.x();
float y = n.y();
float w = n.getTextData().getWidth();
float h = n.getTextData().getHeight();
float radius = n.getRadius();
if (w > 0 && h > 0) {
// Get the rectangle occupied by the node (size + label)
......@@ -147,12 +150,12 @@ public class LabelAdjust extends AbstractLayout implements Layout {
//Compute repulsion - with neighbours in the 8 quadnodes around the node
for (Node n : correctNodes) {
timeStamp++;
LabelAdjustLayoutData layoutData = n.getNodeData().getLayoutData();
LabelAdjustLayoutData layoutData = n.getLayoutData();
QuadNode quad = quadTree.getQuadNode(layoutData.labelAdjustQuadNode);
//Repulse with adjacent quad - but only one per pair of nodes, timestamp is guaranteeing that
for (Node neighbour : quadTree.getAdjacentNodes(quad.row, quad.col)) {
LabelAdjustLayoutData neighborLayoutData = neighbour.getNodeData().getLayoutData();
LabelAdjustLayoutData neighborLayoutData = neighbour.getLayoutData();
if (neighbour != n && neighborLayoutData.freeze < timeStamp) {
boolean collision = repulse(n, neighbour);
someCollision = someCollision || collision;
......@@ -166,15 +169,15 @@ public class LabelAdjust extends AbstractLayout implements Layout {
} else {
// apply forces
for (Node n : correctNodes) {
LabelAdjustLayoutData layoutData = n.getNodeData().getLayoutData();
if (!n.getNodeData().isFixed()) {
LabelAdjustLayoutData layoutData = n.getLayoutData();
if (!n.isFixed()) {
layoutData.dx *= speed;
layoutData.dy *= speed;
float x = n.getNodeData().x() + layoutData.dx;
float y = n.getNodeData().y() + layoutData.dy;
float x = n.x() + layoutData.dx;
float y = n.y() + layoutData.dy;
n.getNodeData().setX(x);
n.getNodeData().setY(y);
n.setX(x);
n.setY(y);
}
}
}
......@@ -184,15 +187,15 @@ public class LabelAdjust extends AbstractLayout implements Layout {
private boolean repulse(Node n1, Node n2) {
boolean collision = false;
float n1x = n1.getNodeData().x();
float n1y = n1.getNodeData().y();
float n2x = n2.getNodeData().x();
float n2y = n2.getNodeData().y();
float n1w = n1.getNodeData().getTextData().getWidth();
float n2w = n2.getNodeData().getTextData().getWidth();
float n1h = n1.getNodeData().getTextData().getHeight();
float n2h = n2.getNodeData().getTextData().getHeight();
LabelAdjustLayoutData n2Data = n2.getNodeData().getLayoutData();
float n1x = n1.x();
float n1y = n1.y();
float n2x = n2.x();
float n2y = n2.y();
float n1w = n1.getTextData().getWidth();
float n2w = n2.getTextData().getWidth();
float n1h = n1.getTextData().getHeight();
float n2h = n2.getTextData().getHeight();
LabelAdjustLayoutData n2Data = n2.getLayoutData();
double n1xmin = n1x - 0.5 * n1w;
double n2xmin = n2x - 0.5 * n2w;
......@@ -208,9 +211,9 @@ public class LabelAdjust extends AbstractLayout implements Layout {
double xDist = n2x - n1x;
double yDist = n2y - n1y;
double dist = Math.sqrt(xDist * xDist + yDist * yDist);
boolean sphereCollision = dist < radiusScale * (n1.getNodeData().getRadius() + n2.getNodeData().getRadius());
boolean sphereCollision = dist < radiusScale * (n1.getRadius() + n2.getRadius());
if (sphereCollision) {
double f = 0.1 * n1.getNodeData().getRadius() / dist;
double f = 0.1 * n1.getRadius() / dist;
if (dist > 0) {
n2Data.dx = (float) (n2Data.dx + xDist / dist * f);
n2Data.dy = (float) (n2Data.dy + yDist / dist * f);
......@@ -255,7 +258,7 @@ public class LabelAdjust extends AbstractLayout implements Layout {
public void endAlgo() {
for (Node n : graph.getNodes()) {
n.getNodeData().setLayoutData(null);
n.setLayoutData(null);
}
}
......@@ -345,11 +348,11 @@ public class LabelAdjust extends AbstractLayout implements Layout {
}
public void add(Node node) {
float x = node.getNodeData().x();
float y = node.getNodeData().y();
float w = node.getNodeData().getTextData().getWidth();
float h = node.getNodeData().getTextData().getHeight();
float radius = node.getNodeData().getRadius();
float x = node.x();
float y = node.y();
float w = node.getTextData().getWidth();
float h = node.getTextData().getHeight();
float radius = node.getRadius();
// Get the rectangle occupied by the node (size + label)
float nxmin = Math.min(x - w / 2, x - radius);
......@@ -371,7 +374,7 @@ public class LabelAdjust extends AbstractLayout implements Layout {
//Get the node center
int centerX = (int) Math.floor((COLUMNS - 1) * (x - xmin) / (xmax - xmin));
int centerY = (int) Math.floor((ROWS - 1) * (((ymax - ymin) - (y - ymin)) / (ymax - ymin)));
LabelAdjustLayoutData layoutData = node.getNodeData().getLayoutData();
LabelAdjustLayoutData layoutData = node.getLayoutData();
layoutData.labelAdjustQuadNode = quads[centerY * COLUMNS + centerX].index;
}
......
/*
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.
*/
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.layout.plugin.labelAdjust;
import javax.swing.Icon;
......@@ -58,36 +58,44 @@ public class LabelAdjustBuilder implements LayoutBuilder {
private LabelAdjustLayoutUI ui = new LabelAdjustLayoutUI();
@Override
public String getName() {
return NbBundle.getMessage(LabelAdjustBuilder.class, "name");
}
@Override
public LabelAdjust buildLayout() {
return new LabelAdjust(this);
}
@Override
public LayoutUI getUI() {
return ui;
}
private static class LabelAdjustLayoutUI implements LayoutUI {
@Override
public String getDescription() {
return NbBundle.getMessage(LabelAdjustBuilder.class, "description");
}
@Override
public Icon getIcon() {
return null;
}
@Override
public JPanel getSimplePanel(Layout layout) {
return null;
}
@Override
public int getQualityRank() {
return -1;
}
@Override
public int getSpeedRank() {
return -1;
}
......
/*
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.
*/
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.layout.plugin.random;
import javax.swing.Icon;
......@@ -53,41 +53,49 @@ import org.openide.util.lookup.ServiceProvider;
*
* @author Helder Suzuki <heldersuzuki@gephi.org>
*/
@ServiceProvider(service=LayoutBuilder.class)
@ServiceProvider(service = LayoutBuilder.class)
public class Random implements LayoutBuilder {
private RandomLayoutUI ui = new RandomLayoutUI();
@Override
public String getName() {
return NbBundle.getMessage(Random.class, "Random.name");
}
@Override
public Layout buildLayout() {
return new RandomLayout(this, 50);
}
@Override
public LayoutUI getUI() {
return ui;
}
private static class RandomLayoutUI implements LayoutUI {
@Override
public String getDescription() {
return NbBundle.getMessage(Random.class, "Random.description");
}
@Override
public Icon getIcon() {
return null;
}
@Override
public JPanel getSimplePanel(Layout layout) {
return null;
}
@Override
public int getQualityRank() {
return -1;
}
@Override
public int getSpeedRank() {
return -1;
}
......
/*
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.
*/
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.layout.plugin.random;
import java.util.ArrayList;
......@@ -69,16 +69,17 @@ public class RandomLayout extends AbstractLayout implements Layout {
random = new Random();
}
@Override
public void initAlgo() {
converged = false;
graph = graphModel.getGraphVisible();
}
@Override
public void goAlgo() {
graph = graphModel.getGraphVisible();
graph = graphModel.getGraph(graphModel.getVisibleView());
for (Node n : graph.getNodes()) {
n.getNodeData().setX((float) (-size / 2 + size * random.nextDouble()));
n.getNodeData().setY((float) (-size / 2 + size * random.nextDouble()));
n.setX((float) (-size / 2 + size * random.nextDouble()));
n.setY((float) (-size / 2 + size * random.nextDouble()));
}
converged = true;
}
......@@ -88,14 +89,17 @@ public class RandomLayout extends AbstractLayout implements Layout {
return !converged;
}
@Override
public void endAlgo() {
graph = null;
}
@Override
public LayoutProperty[] getProperties() {
List<LayoutProperty> properties = new ArrayList<LayoutProperty>();
try {
properties.add(LayoutProperty.createProperty(
this, Double.class,
this, Double.class,
NbBundle.getMessage(getClass(), "Random.spaceSize.name"),
null,
"Random.spaceSize.name",
......@@ -107,6 +111,7 @@ public class RandomLayout extends AbstractLayout implements Layout {
return properties.toArray(new LayoutProperty[0]);
}
@Override
public void resetPropertiesValues() {
}
......
/*
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.
*/
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.layout.plugin.rotate;
import javax.swing.Icon;
......@@ -53,41 +53,49 @@ import org.openide.util.lookup.ServiceProvider;
*
* @author Helder Suzuki <heldersuzuki@gephi.org>
*/
@ServiceProvider(service=LayoutBuilder.class)
@ServiceProvider(service = LayoutBuilder.class)
public class ClockwiseRotate implements LayoutBuilder {
private ClockwiseRotateLayoutUI ui = new ClockwiseRotateLayoutUI();
@Override
public Layout buildLayout() {
return new RotateLayout(this, 90);
}
@Override
public String getName() {
return NbBundle.getMessage(ClockwiseRotate.class, "clockwise.name");
}
@Override
public LayoutUI getUI() {
return ui;
}
private static class ClockwiseRotateLayoutUI implements LayoutUI {
@Override
public String getDescription() {
return NbBundle.getMessage(ClockwiseRotate.class, "clockwise.description");
}
@Override
public Icon getIcon() {
return null;
}
@Override
public JPanel getSimplePanel(Layout layout) {
return null;
}
@Override
public int getQualityRank() {
return -1;
}
@Override
public int getSpeedRank() {
return -1;
}
......
/*
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.
*/
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.layout.plugin.rotate;
import javax.swing.Icon;
......@@ -53,41 +53,49 @@ import org.openide.util.lookup.ServiceProvider;
*
* @author Helder Suzuki <heldersuzuki@gephi.org>
*/
@ServiceProvider(service=LayoutBuilder.class)
@ServiceProvider(service = LayoutBuilder.class)
public class CounterClockwiseRotate implements LayoutBuilder {
private CounterClockwiseRotateLayoutUI ui = new CounterClockwiseRotateLayoutUI();
@Override
public Layout buildLayout() {
return new RotateLayout(this, 90);
}
@Override
public String getName() {
return NbBundle.getMessage(CounterClockwiseRotate.class, "counterclockwise.name");
}
@Override
public LayoutUI getUI() {
return ui;
}
private static class CounterClockwiseRotateLayoutUI implements LayoutUI {
@Override
public String getDescription() {
return NbBundle.getMessage(CounterClockwiseRotate.class, "counterclockwise.description");
}
@Override
public Icon getIcon() {
return null;
}
@Override
public JPanel getSimplePanel(Layout layout) {
return null;
}
@Override
public int getQualityRank() {
return -1;
}
@Override
public int getSpeedRank() {
return -1;
}
......
/*
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.
*/
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.layout.plugin.rotate;
import java.util.ArrayList;
......@@ -53,6 +53,7 @@ import org.openide.util.NbBundle;
/**
* Sample layout that simply rotates the graph.
*
* @author Helder Suzuki <heldersuzuki@gephi.org>
*/
public class RotateLayout extends AbstractLayout implements Layout {
......@@ -65,39 +66,43 @@ public class RotateLayout extends AbstractLayout implements Layout {
this.angle = angle;
}
@Override
public void initAlgo() {
graph = graphModel.getGraphVisible();
setConverged(false);
}
@Override
public void goAlgo() {
graph = graphModel.getGraphVisible();
graph = graphModel.getGraph(graphModel.getVisibleView());
double sin = Math.sin(getAngle() * Math.PI / 180);
double cos = Math.cos(getAngle() * Math.PI / 180);
double px = 0f;
double py = 0f;
for (Node n : graph.getNodes()) {
double dx = n.getNodeData().x() - px;
double dy = n.getNodeData().y() - py;
double dx = n.x() - px;
double dy = n.y() - py;
n.getNodeData().setX((float) (px + dx * cos - dy * sin));
n.getNodeData().setY((float) (py + dy * cos + dx * sin));
n.setX((float) (px + dx * cos - dy * sin));
n.setY((float) (py + dy * cos + dx * sin));
}
setConverged(true);
}
@Override
public void endAlgo() {
}
@Override
public void resetPropertiesValues() {
}
@Override
public LayoutProperty[] getProperties() {
List<LayoutProperty> properties = new ArrayList<LayoutProperty>();
try {
properties.add(LayoutProperty.createProperty(
this, Double.class,
this, Double.class,
NbBundle.getMessage(getClass(), "clockwise.angle.name"),
null,
"clockwise.angle.name",
......
/*
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.
*/
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.layout.plugin.scale;
import javax.swing.Icon;
......@@ -58,36 +58,44 @@ public class Contract implements LayoutBuilder {
private ContractLayoutUI ui = new ContractLayoutUI();
@Override
public String getName() {
return NbBundle.getMessage(Contract.class, "contract.name");
}
@Override
public ScaleLayout buildLayout() {
return new ScaleLayout(this, 0.8);
}
@Override
public LayoutUI getUI() {
return ui;
}
private static class ContractLayoutUI implements LayoutUI {
@Override
public String getDescription() {
return NbBundle.getMessage(Contract.class, "contract.description");
}
@Override
public Icon getIcon() {
return null;
}
@Override
public JPanel getSimplePanel(Layout layout) {
return null;
}
@Override
public int getQualityRank() {
return -1;
}
@Override
public int getSpeedRank() {
return -1;
}
......
/*
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.
*/
Copyright 2008-2010 Gephi
Authors : Helder Suzuki <heldersuzuki@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.layout.plugin.scale;
import javax.swing.Icon;
......@@ -58,36 +58,44 @@ public class Expand implements LayoutBuilder {
private ExpandLayoutUI ui = new ExpandLayoutUI();
@Override
public String getName() {
return NbBundle.getMessage(Expand.class, "expand.name");
}
@Override
public ScaleLayout buildLayout() {
return new ScaleLayout(this, 1.2);
}
@Override
public LayoutUI getUI() {
return ui;
}
private static class ExpandLayoutUI implements LayoutUI {
@Override
public String getDescription() {
return NbBundle.getMessage(Expand.class, "expand.description");
}
@Override
public Icon getIcon() {
return null;
}
@Override
public JPanel getSimplePanel(Layout layout) {
return null;
}
@Override
public int getQualityRank() {
return -1;
}
@Override
public int getSpeedRank() {
return -1;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册