Skip to content

Commit

Permalink
plot export file specification
Browse files Browse the repository at this point in the history
  • Loading branch information
jjallaire committed May 4, 2011
1 parent fa290c0 commit e25618e
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 11 deletions.
Expand Up @@ -513,8 +513,8 @@ private Size getPlotSize()
// default export options
private ExportPlotOptions exportPlotOptions_ = ExportPlotOptions.create(
ExportPlotOptions.PNG_TYPE,
500,
400,
550,
450,
false);

// size of most recently rendered plot
Expand Down
@@ -1,4 +1,29 @@

.exportTargetLabel {
margin-right: 7px;
}

.imageFormatListBox {
width: 150px;
}

.fileNameTextBox {
margin-top: 4px;
width: 145px;
}

.directoryButton {
margin-left: -2px;
}

.directoryTextBox {
margin-left: -2px;
width: 180px;
border: none;
outline: none;
background: transparent;
}

.imageOptionLabel {
margin-right: 5px;
}
Expand Down Expand Up @@ -37,7 +62,7 @@
}

.verticalSizeOptions .widthAndHeightEntry {
margin-bottom: 8px;
margin-bottom: 4px;
}

.verticalSizeOptions .maintainAspectRatioCheckBox {
Expand All @@ -46,6 +71,6 @@

.verticalSizeOptions .updateImageSizeButton {
margin-left: -2px;
margin-top: 10px;
margin-bottom: 8px;
margin-top: 6px;
margin-bottom: 4px;
}
Expand Up @@ -20,10 +20,15 @@

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

// TODO: limit the initial size of the dialog (and thus the displayed
// image) based on your workbench size

// TODO: checkbox baseline tip from joe

public class ExportPlotDialog extends ModalDialogBase
{
public ExportPlotDialog(PlotsServerOperations server,
Expand All @@ -33,11 +38,10 @@ public ExportPlotDialog(PlotsServerOperations server,
server_ = server;
options_ = options;

setText("Export Plot");
setText("Save Plot as Image");

setButtonAlignment(HasHorizontalAlignment.ALIGN_RIGHT);

ThemedButton closeButton = new ThemedButton("Close", new ClickHandler() {
ThemedButton saveButton = new ThemedButton("Save", new ClickHandler() {
public void onClick(ClickEvent event) {
ExportPlotOptions options = ExportPlotOptions.create(
options_.getType(),
Expand All @@ -48,7 +52,14 @@ public void onClick(ClickEvent event) {
closeDialog();
}
});
addCancelButton(closeButton);
addOkButton(saveButton);
addCancelButton();

viewPlotAfterSavingCheckBox_ =
new CheckBox("View plot after saving");
addLeftWidget(viewPlotAfterSavingCheckBox_);


}

@Override
Expand All @@ -59,6 +70,7 @@ protected Widget createMainWidget()
plotSizer_ = new PlotSizer(options_.getWidth(),
options_.getHeight(),
options_.getKeepRatio(),
new ExportTargetWidget(),
server_,
new PlotSizer.Observer() {
public void onPlotResized(boolean withMouse)
Expand All @@ -85,6 +97,8 @@ protected void onDialogShown()
private ExportPlotOptions options_;

private PlotSizer plotSizer_;

private CheckBox viewPlotAfterSavingCheckBox_;



Expand Down
Expand Up @@ -21,6 +21,12 @@ public interface ExportPlotDialogResources extends ClientBundle
{
public static interface Styles extends CssResource
{
String exportTargetLabel();
String imageFormatListBox();
String fileNameTextBox();
String directoryButton();
String directoryTextBox();

String imagePreview();
String imageOptionLabel();
String imageSizeTextBox();
Expand Down
@@ -0,0 +1,63 @@
package org.rstudio.studio.client.workbench.views.plots.ui.export;

import org.rstudio.core.client.widget.ThemedButton;

import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.TextBox;

public class ExportTargetWidget extends Composite
{
public ExportTargetWidget()
{
ExportPlotDialogResources.Styles styles =
ExportPlotDialogResources.INSTANCE.styles();


Grid grid = new Grid(3, 2);
grid.setCellPadding(0);

Label imageFormatLabel = new Label("Image format:");
imageFormatLabel.setStylePrimaryName(styles.exportTargetLabel());

grid.setWidget(0, 0, imageFormatLabel);
imageFormatListBox_ = new ListBox();
imageFormatListBox_.addItem("PNG");
imageFormatListBox_.setSelectedIndex(0);
imageFormatListBox_.setStylePrimaryName(styles.imageFormatListBox());
grid.setWidget(0, 1, imageFormatListBox_);

Label fileNameLabel = new Label("File name:");
imageFormatLabel.setStylePrimaryName(styles.exportTargetLabel());
grid.setWidget(1, 0, fileNameLabel);
fileNameTextBox_ = new TextBox();
fileNameTextBox_.setStylePrimaryName(styles.fileNameTextBox());
grid.setWidget(1, 1, fileNameTextBox_);


ThemedButton directoryButton = new ThemedButton("Directory...");
directoryButton.setStylePrimaryName(styles.directoryButton());
directoryButton.getElement().getStyle().setMarginLeft(-2, Unit.PX);
grid.setWidget(2, 0, directoryButton);

directoryTextBox_ = new TextBox();
directoryTextBox_.setReadOnly(true);
directoryTextBox_.setStylePrimaryName(styles.directoryTextBox());
grid.setWidget(2, 1, directoryTextBox_);

directoryTextBox_.setText("~/Projects/Analysis");


initWidget(grid);
}



private ListBox imageFormatListBox_;
private TextBox fileNameTextBox_;
private TextBox directoryTextBox_;

}
Expand Up @@ -181,7 +181,7 @@ public void onChange(ChangeEvent event)


// update button
ThemedButton updateButton = new ThemedButton("Update Image Size",
ThemedButton updateButton = new ThemedButton("Update Preview",
new ClickHandler(){
public void onClick(ClickEvent event)
{
Expand Down

0 comments on commit e25618e

Please sign in to comment.