Debug Appearerance and implement apply button
Esse commit está contido em:
+20
-8
@@ -42,9 +42,12 @@
|
||||
package org.gephi.appearance;
|
||||
|
||||
import org.gephi.appearance.api.AppearanceController;
|
||||
import org.gephi.appearance.api.Interpolator;
|
||||
import org.gephi.appearance.api.Function;
|
||||
import org.gephi.appearance.spi.Transformer;
|
||||
import org.gephi.appearance.spi.TransformerUI;
|
||||
import org.gephi.graph.api.Element;
|
||||
import org.gephi.graph.api.ElementIterable;
|
||||
import org.gephi.graph.api.GraphModel;
|
||||
import org.gephi.project.api.ProjectController;
|
||||
import org.gephi.project.api.Workspace;
|
||||
import org.gephi.project.api.WorkspaceListener;
|
||||
@@ -103,6 +106,22 @@ public class AppearanceControllerImpl implements AppearanceController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transform(Function function) {
|
||||
if (model != null) {
|
||||
GraphModel graphModel = model.getGraphModel();
|
||||
ElementIterable<? extends Element> iterable;
|
||||
if (function.getTransformer().isNode()) {
|
||||
iterable = graphModel.getGraphVisible().getNodes();
|
||||
} else {
|
||||
iterable = graphModel.getGraphVisible().getEdges();
|
||||
}
|
||||
for (Element element : iterable) {
|
||||
function.transform(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppearanceModelImpl getModel() {
|
||||
return model;
|
||||
@@ -128,13 +147,6 @@ public class AppearanceControllerImpl implements AppearanceController {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInterpolator(Interpolator interpolator) {
|
||||
if (model != null) {
|
||||
model.setInterpolator(interpolator);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUseLocalScale(boolean useLocalScale) {
|
||||
if (model != null) {
|
||||
|
||||
@@ -43,6 +43,7 @@ package org.gephi.appearance.api;
|
||||
|
||||
import org.gephi.appearance.spi.Transformer;
|
||||
import org.gephi.appearance.spi.TransformerUI;
|
||||
import org.gephi.graph.api.Element;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -50,6 +51,8 @@ import org.gephi.appearance.spi.TransformerUI;
|
||||
*/
|
||||
public interface Function {
|
||||
|
||||
public void transform(Element element);
|
||||
|
||||
public Transformer getTransformer();
|
||||
|
||||
public TransformerUI getUI();
|
||||
|
||||
@@ -41,13 +41,9 @@
|
||||
*/
|
||||
package org.gephi.appearance.api;
|
||||
|
||||
import org.gephi.graph.api.Element;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author mbastian
|
||||
*/
|
||||
public interface SimpleFunction extends Function {
|
||||
|
||||
public void transform(Element element);
|
||||
}
|
||||
|
||||
+3
@@ -58,6 +58,9 @@ public class PartitionElementColorTransformer implements PartitionTransformer<El
|
||||
@Override
|
||||
public void transform(Element element, Partition partition, Object value) {
|
||||
Color color = partition.getColor(value);
|
||||
if (color == null) {
|
||||
color = Color.BLACK;
|
||||
}
|
||||
element.setColor(color);
|
||||
}
|
||||
|
||||
|
||||
+9
-7
@@ -470,13 +470,15 @@ public class AppearanceToolbar implements AppearanceUIModelListener {
|
||||
if (u != null && model.isAttributeTransformerUI(u)) {
|
||||
//Ranking
|
||||
Function selectedColumn = model.getSelectedFunction();
|
||||
if (selectedColumn.isRanking()) {
|
||||
for (AbstractButton btn : rankingSouthControls) {
|
||||
btn.setVisible(true);
|
||||
}
|
||||
} else if (selectedColumn.isPartition()) {
|
||||
for (AbstractButton btn : partitionSouthControls) {
|
||||
btn.setVisible(true);
|
||||
if (selectedColumn != null) {
|
||||
if (selectedColumn.isRanking()) {
|
||||
for (AbstractButton btn : rankingSouthControls) {
|
||||
btn.setVisible(true);
|
||||
}
|
||||
} else if (selectedColumn.isPartition()) {
|
||||
for (AbstractButton btn : partitionSouthControls) {
|
||||
btn.setVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+19
@@ -122,9 +122,11 @@ public class AppearanceTopComponent extends TopComponent implements Lookup.Provi
|
||||
|| pce.getPropertyName().equals(AppearanceUIModelEvent.SELECTED_TRANSFORMER_UI)) {
|
||||
refreshCenterPanel();
|
||||
refreshCombo();
|
||||
refreshControls();
|
||||
} else if (pce.getPropertyName().equals(AppearanceUIModelEvent.SELECTED_FUNCTION)) {
|
||||
refreshCenterPanel();
|
||||
refreshCombo();
|
||||
refreshControls();
|
||||
}
|
||||
// if (pce.getPropertyName().equals(RankingUIModel.LIST_VISIBLE)) {
|
||||
// listButton.setSelected((Boolean) pce.getNewValue());
|
||||
@@ -147,6 +149,7 @@ public class AppearanceTopComponent extends TopComponent implements Lookup.Provi
|
||||
refreshEnable();
|
||||
refreshCenterPanel();
|
||||
refreshCombo();
|
||||
refreshControls();
|
||||
|
||||
//South visible
|
||||
/*
|
||||
@@ -275,6 +278,21 @@ public class AppearanceTopComponent extends TopComponent implements Lookup.Provi
|
||||
});
|
||||
}
|
||||
|
||||
private void refreshControls() {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (model != null) {
|
||||
if (model.getSelectedFunction() != null) {
|
||||
applyButton.setEnabled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
applyButton.setEnabled(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initControls() {
|
||||
//Add ranking controls
|
||||
toolbar.addRankingControl(localScaleButton);
|
||||
@@ -316,6 +334,7 @@ public class AppearanceTopComponent extends TopComponent implements Lookup.Provi
|
||||
applyButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
controller.appearanceController.transform(model.getSelectedFunction());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário