Skip to content

Commit

Permalink
Debug Appearerance and implement apply button
Browse files Browse the repository at this point in the history
  • Loading branch information
mbastian committed Aug 18, 2013
1 parent 70d8a4b commit 30a1053
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 19 deletions.
Expand Up @@ -42,9 +42,12 @@ Development and Distribution License("CDDL") (collectively, the
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;
Expand Down Expand Up @@ -103,6 +106,22 @@ public void disable() {
}
}

@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;
Expand All @@ -128,13 +147,6 @@ public Transformer getTransformer(TransformerUI ui) {
return null;
}

@Override
public void setInterpolator(Interpolator interpolator) {
if (model != null) {
model.setInterpolator(interpolator);
}
}

@Override
public void setUseLocalScale(boolean useLocalScale) {
if (model != null) {
Expand Down
Expand Up @@ -43,13 +43,16 @@ Development and Distribution License("CDDL") (collectively, the

import org.gephi.appearance.spi.Transformer;
import org.gephi.appearance.spi.TransformerUI;
import org.gephi.graph.api.Element;

/**
*
* @author mbastian
*/
public interface Function {

public void transform(Element element);

public Transformer getTransformer();

public TransformerUI getUI();
Expand Down
Expand Up @@ -41,13 +41,9 @@ Development and Distribution License("CDDL") (collectively, the
*/
package org.gephi.appearance.api;

import org.gephi.graph.api.Element;

/**
*
* @author mbastian
*/
public interface SimpleFunction extends Function {

public void transform(Element element);
}
Expand Up @@ -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);
}

Expand Down
Expand Up @@ -470,13 +470,15 @@ protected void refreshControls() {
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);
}
}
}
}
Expand Down
Expand Up @@ -122,9 +122,11 @@ public void propertyChange(PropertyChangeEvent pce) {
|| 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());
Expand All @@ -147,6 +149,7 @@ public void refreshModel(AppearanceUIModel model) {
refreshEnable();
refreshCenterPanel();
refreshCombo();
refreshControls();

//South visible
/*
Expand Down Expand Up @@ -275,6 +278,21 @@ public void itemStateChanged(ItemEvent e) {
});
}

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);
Expand Down Expand Up @@ -316,6 +334,7 @@ public void actionPerformed(ActionEvent e) {
applyButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
controller.appearanceController.transform(model.getSelectedFunction());
}
});

Expand Down

0 comments on commit 30a1053

Please sign in to comment.