Update Chart Viewer
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-resources-widget@101628 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
0125cf539b
commit
128c420b0b
|
@ -42,6 +42,7 @@
|
||||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="output" path="target/tabular-data-resources-widget-1.0.0-SNAPSHOT/WEB-INF/classes"/>
|
<classpathentry kind="output" path="target/tabular-data-resources-widget-1.0.0-SNAPSHOT/WEB-INF/classes"/>
|
||||||
|
|
1
pom.xml
1
pom.xml
|
@ -342,4 +342,5 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
<packaging>war</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -35,6 +35,7 @@ public class ResourcesWidgetEntry implements EntryPoint {
|
||||||
//dialog.show();
|
//dialog.show();
|
||||||
|
|
||||||
resourceTDDescriptor=new ResourceTDDescriptor();
|
resourceTDDescriptor=new ResourceTDDescriptor();
|
||||||
|
resourceTDDescriptor.setName("Test Chart");
|
||||||
ChartViewerDialog chartDialog=new ChartViewerDialog(resourceTDDescriptor, trId, eventBus, true);
|
ChartViewerDialog chartDialog=new ChartViewerDialog(resourceTDDescriptor, trId, eventBus, true);
|
||||||
chartDialog.show();
|
chartDialog.show();
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@ import com.allen_sauer.gwt.log.client.Log;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.event.dom.client.MouseUpEvent;
|
import com.google.gwt.event.dom.client.MouseUpEvent;
|
||||||
import com.google.gwt.event.dom.client.MouseUpHandler;
|
import com.google.gwt.event.dom.client.MouseUpHandler;
|
||||||
|
import com.google.gwt.event.dom.client.MouseWheelEvent;
|
||||||
|
import com.google.gwt.event.dom.client.MouseWheelHandler;
|
||||||
import com.google.gwt.event.logical.shared.SelectionEvent;
|
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||||
import com.google.gwt.event.logical.shared.SelectionHandler;
|
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||||
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
||||||
|
@ -25,11 +27,13 @@ import com.google.gwt.safehtml.shared.SafeUri;
|
||||||
import com.google.gwt.safehtml.shared.UriUtils;
|
import com.google.gwt.safehtml.shared.UriUtils;
|
||||||
import com.google.gwt.user.client.Event;
|
import com.google.gwt.user.client.Event;
|
||||||
import com.google.gwt.user.client.Timer;
|
import com.google.gwt.user.client.Timer;
|
||||||
|
import com.google.gwt.user.client.Window;
|
||||||
import com.google.gwt.user.client.ui.HasValue;
|
import com.google.gwt.user.client.ui.HasValue;
|
||||||
import com.google.web.bindery.event.shared.EventBus;
|
import com.google.web.bindery.event.shared.EventBus;
|
||||||
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
|
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
|
||||||
import com.sencha.gxt.chart.client.draw.DrawComponent;
|
import com.sencha.gxt.chart.client.draw.DrawComponent;
|
||||||
import com.sencha.gxt.chart.client.draw.Scaling;
|
import com.sencha.gxt.chart.client.draw.Scaling;
|
||||||
|
import com.sencha.gxt.chart.client.draw.Translation;
|
||||||
import com.sencha.gxt.chart.client.draw.sprite.ImageSprite;
|
import com.sencha.gxt.chart.client.draw.sprite.ImageSprite;
|
||||||
import com.sencha.gxt.chart.client.draw.sprite.Sprite;
|
import com.sencha.gxt.chart.client.draw.sprite.Sprite;
|
||||||
import com.sencha.gxt.chart.client.draw.sprite.SpriteOutEvent;
|
import com.sencha.gxt.chart.client.draw.sprite.SpriteOutEvent;
|
||||||
|
@ -43,13 +47,13 @@ import com.sencha.gxt.core.client.util.ToggleGroup;
|
||||||
import com.sencha.gxt.data.shared.LabelProvider;
|
import com.sencha.gxt.data.shared.LabelProvider;
|
||||||
import com.sencha.gxt.data.shared.ListStore;
|
import com.sencha.gxt.data.shared.ListStore;
|
||||||
import com.sencha.gxt.widget.core.client.FramedPanel;
|
import com.sencha.gxt.widget.core.client.FramedPanel;
|
||||||
|
import com.sencha.gxt.widget.core.client.button.TextButton;
|
||||||
import com.sencha.gxt.widget.core.client.button.ToggleButton;
|
import com.sencha.gxt.widget.core.client.button.ToggleButton;
|
||||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
||||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||||
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
||||||
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
||||||
import com.sencha.gxt.widget.core.client.form.ComboBox;
|
import com.sencha.gxt.widget.core.client.form.ComboBox;
|
||||||
import com.sencha.gxt.widget.core.client.info.Info;
|
|
||||||
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,7 +81,7 @@ public class ChartViewerPanel extends FramedPanel {
|
||||||
ZOOMIN, ZOOMOUT, MOVE
|
ZOOMIN, ZOOMOUT, MOVE
|
||||||
};
|
};
|
||||||
|
|
||||||
private Operation activeOperation = Operation.ZOOMIN;
|
private Operation activeOperation;
|
||||||
private Sprite activeSprite;
|
private Sprite activeSprite;
|
||||||
|
|
||||||
private Vector2D startPosition;
|
private Vector2D startPosition;
|
||||||
|
@ -94,11 +98,12 @@ public class ChartViewerPanel extends FramedPanel {
|
||||||
|
|
||||||
private ImageSprite chartSprite;
|
private ImageSprite chartSprite;
|
||||||
|
|
||||||
private int MAX_SCALE_FACTOR = 20;
|
private int MAX_SCALE_FACTOR = 32;
|
||||||
private int MIN_SCALE_FACTOR = 0;
|
private int MIN_SCALE_FACTOR = 0;
|
||||||
private double scaleFactor = 0;
|
private double scaleFactor = 0;
|
||||||
|
|
||||||
private Vector2D baseDimension;
|
private Vector2D fitScale;
|
||||||
|
private Vector2D chartScale;
|
||||||
private Vector2D chartDimension;
|
private Vector2D chartDimension;
|
||||||
|
|
||||||
private DrawComponent paint;
|
private DrawComponent paint;
|
||||||
|
@ -112,6 +117,7 @@ public class ChartViewerPanel extends FramedPanel {
|
||||||
private Timer mouseTimer;
|
private Timer mouseTimer;
|
||||||
private Vector2D chartTranslation;
|
private Vector2D chartTranslation;
|
||||||
private ComboBox<ZoomLevelElement> comboZoomLevel;
|
private ComboBox<ZoomLevelElement> comboZoomLevel;
|
||||||
|
private TextButton btnOpenInWindow;
|
||||||
|
|
||||||
public ChartViewerPanel(ChartViewerDialog parent,
|
public ChartViewerPanel(ChartViewerDialog parent,
|
||||||
ResourceTDDescriptor resourceTDDescriptor, TRId trId,
|
ResourceTDDescriptor resourceTDDescriptor, TRId trId,
|
||||||
|
@ -123,6 +129,8 @@ public class ChartViewerPanel extends FramedPanel {
|
||||||
ResourceTDDescriptor resourceTDDescriptor, TRId trId,
|
ResourceTDDescriptor resourceTDDescriptor, TRId trId,
|
||||||
EventBus eventBus, boolean test) {
|
EventBus eventBus, boolean test) {
|
||||||
super();
|
super();
|
||||||
|
ResourceBundle.INSTANCE.resourceCSS().ensureInjected();
|
||||||
|
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.resourceTDDescriptor = resourceTDDescriptor;
|
this.resourceTDDescriptor = resourceTDDescriptor;
|
||||||
this.test = test;
|
this.test = test;
|
||||||
|
@ -243,20 +251,19 @@ public class ChartViewerPanel extends FramedPanel {
|
||||||
VerticalLayoutContainer layout = new VerticalLayoutContainer();
|
VerticalLayoutContainer layout = new VerticalLayoutContainer();
|
||||||
add(layout);
|
add(layout);
|
||||||
|
|
||||||
|
|
||||||
// ToolBar
|
// ToolBar
|
||||||
ToolBar toolBar = new ToolBar();
|
ToolBar toolBar = new ToolBar();
|
||||||
|
|
||||||
btnZoomIn = new ToggleButton();
|
btnZoomIn = new ToggleButton();
|
||||||
btnZoomIn.setValue(true);
|
btnZoomIn.setValue(false);
|
||||||
btnZoomIn.setIcon(ResourceBundle.INSTANCE.magnifierZoomIn());
|
btnZoomIn.setIcon(ResourceBundle.INSTANCE.magnifierZoomIn());
|
||||||
btnZoomIn.setToolTip("Zoom In");
|
btnZoomIn.setToolTip("Zoom In");
|
||||||
btnZoomIn.addSelectHandler(new SelectHandler() {
|
btnZoomIn.addSelectHandler(new SelectHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSelect(SelectEvent event) {
|
public void onSelect(SelectEvent event) {
|
||||||
paint.setStyleName(ResourceBundle.INSTANCE.resourceCSS()
|
chartSprite.setCursor("zoom-in");
|
||||||
.getCursorZoomIn());
|
forceLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -270,8 +277,8 @@ public class ChartViewerPanel extends FramedPanel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSelect(SelectEvent event) {
|
public void onSelect(SelectEvent event) {
|
||||||
paint.setStyleName(ResourceBundle.INSTANCE.resourceCSS()
|
chartSprite.setCursor("zoom-out");
|
||||||
.getCursorZoomOut());
|
forceLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -285,8 +292,7 @@ public class ChartViewerPanel extends FramedPanel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSelect(SelectEvent event) {
|
public void onSelect(SelectEvent event) {
|
||||||
paint.setStyleName(ResourceBundle.INSTANCE.resourceCSS()
|
chartSprite.setCursor("move");
|
||||||
.getCursorZoomOut());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -321,9 +327,8 @@ public class ChartViewerPanel extends FramedPanel {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ZoomLevelPropertiesCombo props = GWT
|
||||||
|
.create(ZoomLevelPropertiesCombo.class);
|
||||||
ZoomLevelPropertiesCombo props = GWT.create(ZoomLevelPropertiesCombo.class);
|
|
||||||
ListStore<ZoomLevelElement> storeZoomLevelTypes = new ListStore<ZoomLevelElement>(
|
ListStore<ZoomLevelElement> storeZoomLevelTypes = new ListStore<ZoomLevelElement>(
|
||||||
props.id());
|
props.id());
|
||||||
|
|
||||||
|
@ -334,20 +339,29 @@ public class ChartViewerPanel extends FramedPanel {
|
||||||
comboZoomLevel = new ComboBox<ZoomLevelElement>(storeZoomLevelTypes,
|
comboZoomLevel = new ComboBox<ZoomLevelElement>(storeZoomLevelTypes,
|
||||||
props.label());
|
props.label());
|
||||||
|
|
||||||
|
|
||||||
Log.trace("Combo created");
|
Log.trace("Combo created");
|
||||||
|
|
||||||
addHandlersForComboZoomLevel(props.label());
|
addHandlersForComboZoomLevel(props.label());
|
||||||
|
|
||||||
|
|
||||||
comboZoomLevel.setEmptyText("Zoom Level");
|
comboZoomLevel.setEmptyText("Zoom Level");
|
||||||
comboZoomLevel.setItemId("ComboZoomLevel");
|
comboZoomLevel.setItemId("ComboZoomLevel");
|
||||||
comboZoomLevel.setWidth(COMBO_ZOOM_LEVEL_WIDTH);
|
comboZoomLevel.setWidth(COMBO_ZOOM_LEVEL_WIDTH);
|
||||||
comboZoomLevel.setEditable(false);
|
comboZoomLevel.setEditable(false);
|
||||||
comboZoomLevel.setTriggerAction(TriggerAction.ALL);
|
comboZoomLevel.setTriggerAction(TriggerAction.ALL);
|
||||||
|
|
||||||
toolBar.add(comboZoomLevel);;
|
toolBar.add(comboZoomLevel);
|
||||||
|
//
|
||||||
|
btnOpenInWindow = new TextButton();
|
||||||
|
btnOpenInWindow.setIcon(ResourceBundle.INSTANCE.application());
|
||||||
|
btnOpenInWindow.setToolTip("Open in new window");
|
||||||
|
btnOpenInWindow.addSelectHandler(new SelectHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
openInNewWindow();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
toolBar.add(btnOpenInWindow);
|
||||||
|
|
||||||
// Paint
|
// Paint
|
||||||
paint = new DrawComponent();
|
paint = new DrawComponent();
|
||||||
|
@ -390,15 +404,36 @@ public class ChartViewerPanel extends FramedPanel {
|
||||||
}
|
}
|
||||||
}, MouseUpEvent.getType());
|
}, MouseUpEvent.getType());
|
||||||
|
|
||||||
layout.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
|
|
||||||
|
|
||||||
layout.add(paint, new VerticalLayoutData(1, -1, new Margins(0)));
|
paint.addDomHandler(new MouseWheelHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMouseWheel(MouseWheelEvent event) {
|
||||||
|
spriteMouseWheel(event);
|
||||||
|
|
||||||
|
}
|
||||||
|
}, MouseWheelEvent.getType());
|
||||||
|
|
||||||
|
|
||||||
|
layout.add(toolBar, new VerticalLayoutData(1, 26, new Margins(0)));
|
||||||
|
|
||||||
|
layout.add(paint, new VerticalLayoutData(1, 1, new Margins(0)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected void openInNewWindow() {
|
||||||
|
String link;
|
||||||
|
if (test) {
|
||||||
|
link = testImageResource.getSafeUri().asString();
|
||||||
|
} else {
|
||||||
|
link = chartImageResource.getSafeUri().asString();
|
||||||
|
}
|
||||||
|
Log.debug("Retrieved link: " + link);
|
||||||
|
Window.open(link, resourceTDDescriptor.getName(), "");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected void drawInit() {
|
protected void drawInit() {
|
||||||
|
|
||||||
|
@ -414,32 +449,36 @@ public class ChartViewerPanel extends FramedPanel {
|
||||||
paint.addSprite(chartSprite);
|
paint.addSprite(chartSprite);
|
||||||
|
|
||||||
if (test) {
|
if (test) {
|
||||||
|
|
||||||
Log.debug("testImageResource width:" + testImageResource.getWidth()
|
Log.debug("testImageResource width:" + testImageResource.getWidth()
|
||||||
+ " height:" + testImageResource.getHeight());
|
+ " height:" + testImageResource.getHeight());
|
||||||
baseDimension = new Vector2D(new Double(DRAW_WIDTH_INT)
|
fitScale = new Vector2D(new Double(DRAW_WIDTH_INT)
|
||||||
/ testImageResource.getWidth(), new Double(DRAW_HEIGHT_INT)
|
/ testImageResource.getWidth(), new Double(DRAW_HEIGHT_INT)
|
||||||
/ testImageResource.getHeight());
|
/ testImageResource.getHeight());
|
||||||
|
chartDimension = new Vector2D(testImageResource.getWidth(),
|
||||||
|
testImageResource.getHeight());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log.debug("chartImageResource width:"
|
Log.debug("chartImageResource width:"
|
||||||
+ chartImageResource.getWidth() + " height:"
|
+ chartImageResource.getWidth() + " height:"
|
||||||
+ chartImageResource.getHeight());
|
+ chartImageResource.getHeight());
|
||||||
baseDimension = new Vector2D(new Double(DRAW_WIDTH_INT)
|
fitScale = new Vector2D(new Double(DRAW_WIDTH_INT)
|
||||||
/ chartImageResource.getWidth(),
|
/ chartImageResource.getWidth(),
|
||||||
new Double(DRAW_HEIGHT_INT)
|
new Double(DRAW_HEIGHT_INT)
|
||||||
/ chartImageResource.getHeight());
|
/ chartImageResource.getHeight());
|
||||||
|
chartDimension = new Vector2D(chartImageResource.getWidth(),
|
||||||
|
chartImageResource.getHeight());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.debug("Offset width:" + DRAW_WIDTH_INT + " height:"
|
Log.debug("Offset width:" + DRAW_WIDTH_INT + " height:"
|
||||||
+ DRAW_HEIGHT_INT);
|
+ DRAW_HEIGHT_INT);
|
||||||
Log.debug("Base Width: " + baseDimension.getX() + ", Base Height:"
|
Log.debug("Fit Scale: " + fitScale);
|
||||||
+ baseDimension.getY());
|
Log.debug("Chart Dimension: "+chartDimension);
|
||||||
|
chartSprite.setScaling(new Scaling(fitScale.getX(), fitScale.getY()));
|
||||||
|
|
||||||
chartSprite.setScaling(new Scaling(baseDimension.getX(), baseDimension
|
chartScale = fitScale.copy();
|
||||||
.getY()));
|
chartTranslation = new Vector2D();
|
||||||
|
|
||||||
chartDimension = baseDimension.copy();
|
|
||||||
chartTranslation=new Vector2D();
|
|
||||||
paint.redrawSurfaceForced();
|
paint.redrawSurfaceForced();
|
||||||
|
|
||||||
// Image image = new Image(chartImageResource.getSafeUri());
|
// Image image = new Image(chartImageResource.getSafeUri());
|
||||||
|
@ -451,7 +490,7 @@ public class ChartViewerPanel extends FramedPanel {
|
||||||
mouseTimer = new Timer() {
|
mouseTimer = new Timer() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (activeSprite != null){
|
if (activeSprite != null) {
|
||||||
if (activeSprite == chartSprite) {
|
if (activeSprite == chartSprite) {
|
||||||
actionOnChartSpriteWhenMouseLeftDown();
|
actionOnChartSpriteWhenMouseLeftDown();
|
||||||
}
|
}
|
||||||
|
@ -474,8 +513,8 @@ public class ChartViewerPanel extends FramedPanel {
|
||||||
browseEvent.getClientY());
|
browseEvent.getClientY());
|
||||||
if (activeSprite != null) {
|
if (activeSprite != null) {
|
||||||
if (activeSprite == chartSprite) {
|
if (activeSprite == chartSprite) {
|
||||||
if (activeOperation.compareTo(Operation.ZOOMIN)==0
|
if (activeOperation.compareTo(Operation.ZOOMIN) == 0
|
||||||
|| activeOperation.compareTo(Operation.ZOOMOUT)==0) {
|
|| activeOperation.compareTo(Operation.ZOOMOUT) == 0) {
|
||||||
actionOnChartSpriteWhenMouseLeftDown();
|
actionOnChartSpriteWhenMouseLeftDown();
|
||||||
comboZoomLevel.reset();
|
comboZoomLevel.reset();
|
||||||
comboZoomLevel.redraw();
|
comboZoomLevel.redraw();
|
||||||
|
@ -493,17 +532,19 @@ public class ChartViewerPanel extends FramedPanel {
|
||||||
endPosition = new Vector2D(event.getClientX(), event.getClientY());
|
endPosition = new Vector2D(event.getClientX(), event.getClientY());
|
||||||
displacement = startPosition.sub(endPosition);
|
displacement = startPosition.sub(endPosition);
|
||||||
activeSprite = null;
|
activeSprite = null;
|
||||||
if(mouseTimer!=null){
|
if (mouseTimer != null) {
|
||||||
mouseTimer.cancel();
|
mouseTimer.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected void spriteLeave(SpriteOutEvent event) {
|
protected void spriteLeave(SpriteOutEvent event) {
|
||||||
Event browseEvent = event.getBrowserEvent();
|
Event browseEvent = event.getBrowserEvent();
|
||||||
Log.debug("Leave Position: " + browseEvent.getClientX() + ", "
|
Log.debug("Leave Position: " + browseEvent.getClientX() + ", "
|
||||||
+ browseEvent.getClientY());
|
+ browseEvent.getClientY());
|
||||||
activeSprite = null;
|
activeSprite = null;
|
||||||
if(mouseTimer!=null){
|
if (mouseTimer != null) {
|
||||||
mouseTimer.cancel();
|
mouseTimer.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -529,6 +570,19 @@ public class ChartViewerPanel extends FramedPanel {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void spriteMouseWheel(MouseWheelEvent event) {
|
||||||
|
int deltaY=event.getDeltaY();
|
||||||
|
Log.debug("Wheel: "+deltaY);
|
||||||
|
if(deltaY<0){
|
||||||
|
zoomIn();
|
||||||
|
} else {
|
||||||
|
zoomOut();
|
||||||
|
}
|
||||||
|
draw();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void actionOnChartSpriteWhenMove() {
|
protected void actionOnChartSpriteWhenMove() {
|
||||||
Log.debug("Operation:" + activeOperation);
|
Log.debug("Operation:" + activeOperation);
|
||||||
switch (activeOperation) {
|
switch (activeOperation) {
|
||||||
|
@ -548,7 +602,7 @@ public class ChartViewerPanel extends FramedPanel {
|
||||||
|
|
||||||
protected void actionOnChartSpriteWhenMouseLeftDown() {
|
protected void actionOnChartSpriteWhenMouseLeftDown() {
|
||||||
Log.debug("Operation:" + activeOperation);
|
Log.debug("Operation:" + activeOperation);
|
||||||
switch(activeOperation){
|
switch (activeOperation) {
|
||||||
case MOVE:
|
case MOVE:
|
||||||
break;
|
break;
|
||||||
case ZOOMIN:
|
case ZOOMIN:
|
||||||
|
@ -564,15 +618,15 @@ public class ChartViewerPanel extends FramedPanel {
|
||||||
draw();
|
draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void zoomIn() {
|
protected void zoomIn() {
|
||||||
if (scaleFactor < MAX_SCALE_FACTOR) {
|
if (scaleFactor < MAX_SCALE_FACTOR) {
|
||||||
scaleFactor++;
|
scaleFactor++;
|
||||||
}
|
}
|
||||||
|
|
||||||
chartDimension = baseDimension.multiply(1 + scaleFactor / 10);
|
chartScale = fitScale.multiply(1 + scaleFactor / 10);
|
||||||
chartSprite.setScaling(new Scaling(chartDimension.getX(),
|
chartSprite
|
||||||
chartDimension.getY()));
|
.setScaling(new Scaling(chartScale.getX(), chartScale.getY()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void zoomOut() {
|
protected void zoomOut() {
|
||||||
|
@ -580,16 +634,19 @@ public class ChartViewerPanel extends FramedPanel {
|
||||||
scaleFactor--;
|
scaleFactor--;
|
||||||
}
|
}
|
||||||
|
|
||||||
chartDimension = baseDimension.multiply(1 + scaleFactor / 10);
|
chartScale = fitScale.multiply(1 + scaleFactor / 10);
|
||||||
chartSprite.setScaling(new Scaling(chartDimension.getX(),
|
chartSprite
|
||||||
chartDimension.getY()));
|
.setScaling(new Scaling(chartScale.getX(), chartScale.getY()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void moveChart() {
|
private void moveChart() {
|
||||||
displacement=displacement.divide(1+scaleFactor/10);
|
displacement = displacement.divide(1 + scaleFactor);
|
||||||
displacement = displacement.negate();
|
displacement = displacement.negate();
|
||||||
chartTranslation=chartTranslation.add(displacement);
|
|
||||||
chartSprite.setTranslation(chartTranslation.getX(), chartTranslation.getY());
|
chartTranslation = chartTranslation.add(displacement);
|
||||||
|
|
||||||
|
chartSprite.setTranslation(chartTranslation.getX(),
|
||||||
|
chartTranslation.getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void draw() {
|
protected void draw() {
|
||||||
|
@ -598,7 +655,6 @@ public class ChartViewerPanel extends FramedPanel {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void addHandlersForComboZoomLevel(
|
private void addHandlersForComboZoomLevel(
|
||||||
final LabelProvider<ZoomLevelElement> label) {
|
final LabelProvider<ZoomLevelElement> label) {
|
||||||
comboZoomLevel
|
comboZoomLevel
|
||||||
|
@ -617,7 +673,19 @@ public class ChartViewerPanel extends FramedPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateZoomLevel(ZoomLevelType type) {
|
protected void updateZoomLevel(ZoomLevelType type) {
|
||||||
switch(type){
|
switch (type) {
|
||||||
|
case P50:
|
||||||
|
zoomLevel50();
|
||||||
|
break;
|
||||||
|
case P75:
|
||||||
|
zoomLevel75();
|
||||||
|
break;
|
||||||
|
case P100:
|
||||||
|
zoomLevel100();
|
||||||
|
break;
|
||||||
|
case P200:
|
||||||
|
zoomLevel200();
|
||||||
|
break;
|
||||||
case Fit:
|
case Fit:
|
||||||
zoomLevelFit();
|
zoomLevelFit();
|
||||||
break;
|
break;
|
||||||
|
@ -632,29 +700,96 @@ public class ChartViewerPanel extends FramedPanel {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void zoomLevelFit(){
|
protected void zoomLevel50() {
|
||||||
chartTranslation=new Vector2D();
|
/*
|
||||||
scaleFactor=MIN_SCALE_FACTOR;
|
* Log.debug("Paint :" + paint.getAbsoluteLeft() + ", " +
|
||||||
|
* paint.getAbsoluteTop()); Log.debug("Paint offset:" +
|
||||||
|
* paint.getOffsetWidth(true) + ", " + paint.getOffsetHeight(true));
|
||||||
|
*
|
||||||
|
* Vector2D center = new Vector2D((paint.getOffsetWidth(true) / 2),
|
||||||
|
* (paint.getOffsetHeight(true) / 2)); Log.debug("Center: " + center);
|
||||||
|
* RectangleSprite rectangleSprite = new RectangleSprite(20, 20,
|
||||||
|
* center.getX(), center.getY()); paint.addSprite(rectangleSprite);
|
||||||
|
*/
|
||||||
|
|
||||||
chartDimension = baseDimension.multiply(1 + scaleFactor / 10);
|
chartTranslation = new Vector2D();
|
||||||
chartSprite.setScaling(new Scaling(chartDimension.getX(),
|
scaleFactor = 2;
|
||||||
chartDimension.getY()));
|
|
||||||
chartSprite.setTranslation(chartTranslation.getX(), chartTranslation.getY());
|
chartScale = fitScale.multiply(1 + scaleFactor / 10);
|
||||||
|
|
||||||
|
chartSprite
|
||||||
|
.setScaling(new Scaling(chartScale.getX(), chartScale.getY()));
|
||||||
|
chartSprite.setTranslation(new Translation(chartTranslation.getX(),
|
||||||
|
chartTranslation.getY()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void zoomLevelMax(){
|
protected void zoomLevel75() {
|
||||||
chartTranslation=new Vector2D();
|
|
||||||
scaleFactor=MAX_SCALE_FACTOR;
|
|
||||||
|
|
||||||
chartDimension = baseDimension.multiply(1 + scaleFactor / 10);
|
chartTranslation = new Vector2D();
|
||||||
chartSprite.setScaling(new Scaling(chartDimension.getX(),
|
scaleFactor = 9;
|
||||||
chartDimension.getY()));
|
|
||||||
chartSprite.setTranslation(chartTranslation.getX(), chartTranslation.getY());
|
chartScale = fitScale.multiply(1 + scaleFactor / 10);
|
||||||
|
|
||||||
|
chartSprite
|
||||||
|
.setScaling(new Scaling(chartScale.getX(), chartScale.getY()));
|
||||||
|
chartSprite.setTranslation(new Translation(chartTranslation.getX(),
|
||||||
|
chartTranslation.getY()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void zoomLevel100() {
|
||||||
|
|
||||||
|
chartTranslation = new Vector2D();
|
||||||
|
scaleFactor = 15;
|
||||||
|
|
||||||
|
chartScale = fitScale.multiply(1 + scaleFactor / 10);
|
||||||
|
|
||||||
|
chartSprite
|
||||||
|
.setScaling(new Scaling(chartScale.getX(), chartScale.getY()));
|
||||||
|
chartSprite.setTranslation(new Translation(chartTranslation.getX(),
|
||||||
|
chartTranslation.getY()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void zoomLevel200() {
|
||||||
|
|
||||||
|
chartTranslation = new Vector2D();
|
||||||
|
scaleFactor = 30;
|
||||||
|
|
||||||
|
chartScale = fitScale.multiply(1 + scaleFactor / 10);
|
||||||
|
|
||||||
|
chartSprite
|
||||||
|
.setScaling(new Scaling(chartScale.getX(), chartScale.getY()));
|
||||||
|
chartSprite.setTranslation(new Translation(chartTranslation.getX(),
|
||||||
|
chartTranslation.getY()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void zoomLevelFit() {
|
||||||
|
chartTranslation = new Vector2D();
|
||||||
|
scaleFactor = MIN_SCALE_FACTOR;
|
||||||
|
|
||||||
|
chartScale = fitScale.multiply(1 + scaleFactor / 10);
|
||||||
|
|
||||||
|
chartSprite
|
||||||
|
.setScaling(new Scaling(chartScale.getX(), chartScale.getY()));
|
||||||
|
chartSprite.setTranslation(chartTranslation.getX(),
|
||||||
|
chartTranslation.getY());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void zoomLevelMax() {
|
||||||
|
chartTranslation = new Vector2D();
|
||||||
|
scaleFactor = MAX_SCALE_FACTOR;
|
||||||
|
|
||||||
|
chartScale = fitScale.multiply(1 + scaleFactor / 10);
|
||||||
|
chartSprite
|
||||||
|
.setScaling(new Scaling(chartScale.getX(), chartScale.getY()));
|
||||||
|
chartSprite.setTranslation(chartTranslation.getX(),
|
||||||
|
chartTranslation.getY());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected void close() {
|
protected void close() {
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
|
|
|
@ -126,6 +126,12 @@ public interface ResourceBundle extends ClientBundle {
|
||||||
@Source("arrow-move.png")
|
@Source("arrow-move.png")
|
||||||
ImageResource move();
|
ImageResource move();
|
||||||
|
|
||||||
|
@Source("application_32.png")
|
||||||
|
ImageResource application32();
|
||||||
|
|
||||||
|
@Source("application.png")
|
||||||
|
ImageResource application();
|
||||||
|
|
||||||
@Source("Resources.css")
|
@Source("Resources.css")
|
||||||
ResourceCSS resourceCSS();
|
ResourceCSS resourceCSS();
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 351 B |
Binary file not shown.
After Width: | Height: | Size: 655 B |
|
@ -19,12 +19,20 @@ public class ZoomLevelStore implements Serializable {
|
||||||
|
|
||||||
protected static ZoomLevelElement fitElement=new ZoomLevelElement(1,ZoomLevelType.Fit);
|
protected static ZoomLevelElement fitElement=new ZoomLevelElement(1,ZoomLevelType.Fit);
|
||||||
protected static ZoomLevelElement maxZoomElement=new ZoomLevelElement(2,ZoomLevelType.MaxZoom);
|
protected static ZoomLevelElement maxZoomElement=new ZoomLevelElement(2,ZoomLevelType.MaxZoom);
|
||||||
|
protected static ZoomLevelElement p50Element=new ZoomLevelElement(3,ZoomLevelType.P50);
|
||||||
|
protected static ZoomLevelElement p75Element=new ZoomLevelElement(4,ZoomLevelType.P75);
|
||||||
|
protected static ZoomLevelElement p100Element=new ZoomLevelElement(5,ZoomLevelType.P100);
|
||||||
|
protected static ZoomLevelElement p200Element=new ZoomLevelElement(6,ZoomLevelType.P200);
|
||||||
|
|
||||||
|
|
||||||
public static ArrayList<ZoomLevelElement> getZoomLevelTypes(){
|
public static ArrayList<ZoomLevelElement> getZoomLevelTypes(){
|
||||||
store=new ArrayList<ZoomLevelElement>();
|
store=new ArrayList<ZoomLevelElement>();
|
||||||
store.add(fitElement);
|
store.add(fitElement);
|
||||||
store.add(maxZoomElement);
|
store.add(maxZoomElement);
|
||||||
|
store.add(p50Element);
|
||||||
|
store.add(p75Element);
|
||||||
|
store.add(p100Element);
|
||||||
|
store.add(p200Element);
|
||||||
return store;
|
return store;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,9 +44,25 @@ public class ZoomLevelStore implements Serializable {
|
||||||
if(selected.compareTo(ZoomLevelType.MaxZoom.toString())==0){
|
if(selected.compareTo(ZoomLevelType.MaxZoom.toString())==0){
|
||||||
position=2;
|
position=2;
|
||||||
} else {
|
} else {
|
||||||
|
if(selected.compareTo(ZoomLevelType.P50.toString())==0){
|
||||||
|
position=3;
|
||||||
|
} else {
|
||||||
|
if(selected.compareTo(ZoomLevelType.P75.toString())==0){
|
||||||
|
position=4;
|
||||||
|
} else {
|
||||||
|
if(selected.compareTo(ZoomLevelType.P100.toString())==0){
|
||||||
|
position=5;
|
||||||
|
} else {
|
||||||
|
if(selected.compareTo(ZoomLevelType.P200.toString())==0){
|
||||||
|
position=6;
|
||||||
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,11 +73,27 @@ public class ZoomLevelStore implements Serializable {
|
||||||
} else {
|
} else {
|
||||||
if(selected.compareTo(ZoomLevelType.MaxZoom.toString())==0){
|
if(selected.compareTo(ZoomLevelType.MaxZoom.toString())==0){
|
||||||
return ZoomLevelType.MaxZoom;
|
return ZoomLevelType.MaxZoom;
|
||||||
|
} else {
|
||||||
|
if(selected.compareTo(ZoomLevelType.P50.toString())==0){
|
||||||
|
return ZoomLevelType.P50;
|
||||||
|
} else {
|
||||||
|
if(selected.compareTo(ZoomLevelType.P75.toString())==0){
|
||||||
|
return ZoomLevelType.P75;
|
||||||
|
} else {
|
||||||
|
if(selected.compareTo(ZoomLevelType.P100.toString())==0){
|
||||||
|
return ZoomLevelType.P100;
|
||||||
|
} else {
|
||||||
|
if(selected.compareTo(ZoomLevelType.P200.toString())==0){
|
||||||
|
return ZoomLevelType.P200;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static ZoomLevelElement selectedZoomLevelElement(String selected){
|
public static ZoomLevelElement selectedZoomLevelElement(String selected){
|
||||||
if(selected.compareTo(ZoomLevelType.Fit.toString())==0){
|
if(selected.compareTo(ZoomLevelType.Fit.toString())==0){
|
||||||
|
@ -61,11 +101,27 @@ public class ZoomLevelStore implements Serializable {
|
||||||
} else {
|
} else {
|
||||||
if(selected.compareTo(ZoomLevelType.MaxZoom.toString())==0){
|
if(selected.compareTo(ZoomLevelType.MaxZoom.toString())==0){
|
||||||
return maxZoomElement;
|
return maxZoomElement;
|
||||||
|
} else {
|
||||||
|
if(selected.compareTo(ZoomLevelType.P50.toString())==0){
|
||||||
|
return p50Element;
|
||||||
|
} else {
|
||||||
|
if(selected.compareTo(ZoomLevelType.P75.toString())==0){
|
||||||
|
return p75Element;
|
||||||
|
} else {
|
||||||
|
if(selected.compareTo(ZoomLevelType.P100.toString())==0){
|
||||||
|
return p100Element;
|
||||||
|
} else {
|
||||||
|
if(selected.compareTo(ZoomLevelType.P200.toString())==0){
|
||||||
|
return p200Element;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,12 @@ package org.gcube.portlets.user.td.resourceswidget.client.store;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public enum ZoomLevelType {
|
public enum ZoomLevelType {
|
||||||
Fit("Fit"), MaxZoom("Max");
|
Fit("Fit"),
|
||||||
|
P50("50%"),
|
||||||
|
P75("75%"),
|
||||||
|
P100("100%"),
|
||||||
|
P200("200%"),
|
||||||
|
MaxZoom("Max");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param text
|
* @param text
|
||||||
|
|
|
@ -27,8 +27,8 @@
|
||||||
<inherits name='org.gcube.portlets.user.td.wizardwidget.Wizard' />
|
<inherits name='org.gcube.portlets.user.td.wizardwidget.Wizard' />
|
||||||
|
|
||||||
<!-- Specify the app entry point class. -->
|
<!-- Specify the app entry point class. -->
|
||||||
<!-- <entry-point class='org.gcube.portlets.user.td.resourceswidget.client.ResourcesWidgetEntry'
|
<entry-point class='org.gcube.portlets.user.td.resourceswidget.client.ResourcesWidgetEntry'
|
||||||
/> -->
|
/>
|
||||||
|
|
||||||
<!-- Specify the paths for translatable code -->
|
<!-- Specify the paths for translatable code -->
|
||||||
<source path='client' />
|
<source path='client' />
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 351 B |
Binary file not shown.
After Width: | Height: | Size: 655 B |
Loading…
Reference in New Issue