List of usage examples for com.google.gwt.visualization.client LegendPosition TOP
LegendPosition TOP
To view the source code for com.google.gwt.visualization.client LegendPosition TOP.
Click Source Link
From source file:de.uni_koeln.spinfo.maalr.webapp.ui.admin.client.stats.NetBar.java
License:Apache License
public NetBar() { chart = new BarChart(); options = Options.create();// w w w. j a v a 2 s.c o m options.setHeight(80); options.setWidth(200); options.setColors("#585858", "#000000"); options.setLegend(LegendPosition.TOP); options.setBackgroundColor("transparent"); options.setLegendBackgroundColor("transparent"); //options.setAxisColor("black"); data = DataTable.create(); data.addColumn(ColumnType.STRING, ""); data.addColumn(ColumnType.NUMBER, "Incoming"); data.addColumn(ColumnType.NUMBER, "Outgoing"); data.addRows(1); initWidget(chart); }
From source file:org.sakaiproject.gradebook.gwt.client.gxt.view.panel.GradeScalePanel.java
License:Educational Community License
public GradeScalePanel(boolean isEditable, final TreeView treeView) { super();/*ww w . j a v a2 s . co m*/ this.isEditable = isEditable; toolbar = new ToolBar(); LabelField gradeScale = new LabelField(i18n.gradeFormatLabel()); toolbar.add(gradeScale); gradeFormatLoader = RestBuilder.getDelayLoader(AppConstants.LIST_ROOT, EnumSet.allOf(GradeFormatKey.class), Method.GET, null, null, GWT.getModuleBaseURL(), AppConstants.REST_FRAGMENT, AppConstants.GRADE_FORMAT_FRAGMENT); gradeFormatLoader.setRemoteSort(true); gradeFormatStore = new ListStore<ModelData>(gradeFormatLoader); gradeFormatStore.setModelComparer(new EntityModelComparer<ModelData>(GradeFormatKey.L_ID.name())); gradeFormatListBox = new ComboBox<ModelData>(); gradeFormatListBox.setAllQuery(null); gradeFormatListBox.setEditable(false); gradeFormatListBox.setFieldLabel("Grade Format"); gradeFormatListBox.setDisplayField(GradeFormatKey.S_NM.name()); gradeFormatListBox.setStore(gradeFormatStore); gradeFormatListBox.setForceSelection(true); gradeFormatListBox.setLazyRender(true); gradeFormatListBox.addSelectionChangedListener(new SelectionChangedListener<ModelData>() { @Override public void selectionChanged(SelectionChangedEvent<ModelData> se) { Boolean isFormatLocked = Boolean.FALSE; Gradebook selectedGradebookModel = Registry.get(AppConstants.CURRENT); Item selectedItemModel = selectedGradebookModel.getGradebookItemModel(); ModelData gradeFormatModel = se.getSelectedItem(); currentGradeScaleId = gradeFormatModel == null ? null : (Long) gradeFormatModel.get(GradeFormatKey.L_ID.name()); if (gradeFormatModel != null) { isFormatLocked = (Boolean) gradeFormatModel.get(GradeFormatKey.B_LK.name()); // Unsure if this could happen, but will guard it anyways.. if (isFormatLocked == null) { isFormatLocked = Boolean.FALSE; } } if (currentGradeScaleId != null && !currentGradeScaleId.equals(selectedItemModel.getGradeScaleId())) { if (isFormatLocked.booleanValue()) { Window.alert(i18n.gradeFormatCannotBeChangedWarning()); loader.load(); } else { showUserFeedback(); Record record = treeView.getTreeStore().getRecord((ItemModel) selectedItemModel); record.beginEdit(); record.set(ItemKey.L_GRD_SCL_ID.name(), currentGradeScaleId); grid.mask(); ItemUpdate itemUpdate = new ItemUpdate(treeView.getTreeStore(), record, selectedItemModel, false); itemUpdate.property = ItemKey.L_GRD_SCL_ID.name(); Dispatcher.forwardEvent(GradebookEvents.UpdateItem.getEventType(), itemUpdate); } } else { loader.load(); } } }); toolbar.add(gradeFormatListBox); // GRBK-982 : Adding tool item separator and chart update toggle button SeparatorToolItem separatorToolItem = new SeparatorToolItem(); separatorToolItem.addStyleName(resources.css().gbGradeScaleSeparatorToolItem()); toolbar.add(separatorToolItem); final String toolTipOn = i18n.gradeScaleChartUpdateToggleToolTipOn(); final String toolTipOff = i18n.gradeScaleChartUpdateToggleToolTipOff(); toggleCheckBox = new NullSensitiveCheckBox(); toggleCheckBox.setToolTip(toolTipOn); toggleCheckBox.setValue(Boolean.TRUE); toggleCheckBox.setBoxLabel(i18n.gradeScaleChartUpdateToggle()); toggleCheckBox.addListener(Events.Change, new Listener<FieldEvent>() { public void handleEvent(FieldEvent be) { boolean isChecked = DataTypeConversionUtil.checkBoolean(((CheckBox) be.getField()).getValue()); if (isChecked) { toggleCheckBox.setToolTip(toolTipOn); statisticsChartPanel.unmask(); if (hasChartUpdates) { getStatisticsChartData(); hasChartUpdates = false; } } else { toggleCheckBox.setToolTip(toolTipOff); statisticsChartPanel.mask(); } } }); toolbar.add(toggleCheckBox); setTopComponent(toolbar); gradeFormatLoader.addListener(Loader.Load, new Listener<LoadEvent>() { public void handleEvent(LoadEvent be) { loadIfPossible(); } }); List<ColumnConfig> configs = new ArrayList<ColumnConfig>(); ColumnConfig column = new ColumnConfig(); column.setId(GradeMapKey.S_LTR_GRD.name()); column.setHeader(i18n.letterGradeHeader()); column.setAlignment(HorizontalAlignment.CENTER); column.setWidth(100); column.setGroupable(false); column.setMenuDisabled(true); column.setSortable(false); configs.add(column); column = new ColumnConfig(); column.setId(GradeMapKey.D_FROM.name()); column.setHeader(i18n.fromHeader()); column.setAlignment(HorizontalAlignment.CENTER); column.setWidth(70); column.setGroupable(false); column.setMenuDisabled(true); column.setSortable(false); column.setNumberFormat(shortNumberFormat); // GRBK-668: We determine if this columns is editable via setState() configs.add(column); column = new ColumnConfig(); column.setId(GradeMapKey.D_TO.name()); column.setHeader(i18n.toHeader()); column.setAlignment(HorizontalAlignment.CENTER); column.setWidth(100); column.setGroupable(false); column.setMenuDisabled(true); column.setSortable(false); column.setNumberFormat(shortNumberFormat); column.setStyle("background-color:#A9A9A9!important;"); // GRBK-874 configs.add(column); loader = RestBuilder.getDelayLoader(AppConstants.LIST_ROOT, EnumSet.allOf(GradeMapKey.class), Method.GET, null, null, GWT.getModuleBaseURL(), AppConstants.REST_FRAGMENT, AppConstants.GRADE_MAP_FRAGMENT); final ListStore<ModelData> store = new ListStore<ModelData>(loader); store.setModelComparer(new EntityModelComparer<ModelData>(GradeMapKey.S_LTR_GRD.name())); loader.addListener(Loader.Load, new Listener<LoadEvent>() { public void handleEvent(LoadEvent be) { grid.unmask(); } }); final ColumnModel cm = new ColumnModel(configs); setBodyBorder(false); setHeaderVisible(false); setHeading("Selected Grade Mapping"); setButtonAlign(HorizontalAlignment.RIGHT); setLayout(new RowLayout()); grid = new EditorGrid<ModelData>(store, cm); grid.setStyleAttribute("borderTop", "none"); grid.setBorders(true); grid.setAutoHeight(true); grid.addListener(Events.ValidateEdit, new Listener<GridEvent<ModelData>>() { public void handleEvent(GridEvent<ModelData> ge) { // By setting ge.doit to false, we ensure that the AfterEdit event is not thrown. Which means we have to throw it ourselves onSuccess ge.stopEvent(); final Record record = ge.getRecord(); Object newValue = ge.getValue(); Object originalValue = ge.getStartValue(); Double nValue = (Double) newValue; Double oValue = (Double) originalValue; // Only update if the user actually changed a grade scale value if (null != nValue && nValue.compareTo(oValue) != 0) { hasGradeScaleUpdates = true; if (!toggleCheckBox.getValue().booleanValue()) { hasChartUpdates = true; } showUserFeedback(); Dispatcher.forwardEvent(GradebookEvents.UpdateGradeMap.getEventType(), new GradeMapUpdate(record, newValue, originalValue)); } } }); closeButton = new AriaButton(i18n.close(), new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent be) { onClose(); Dispatcher.forwardEvent(GradebookEvents.HideEastPanel.getEventType(), Boolean.FALSE); } }); resetToDefaultButton = new AriaButton(i18n.resetGradingScale(), new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { Dispatcher.forwardEvent(GradebookEvents.DeleteGradeMap.getEventType()); } }); // GRBK-668 letterGradeScaleMessage.setStyleAttribute("padding", "10px"); letterGradeScaleMessage.setStyleAttribute("color", "red"); add(letterGradeScaleMessage); horizontalPanel = new HorizontalPanel(); horizontalPanel.add(grid); statisticsChartPanel = new StatisticsChartPanel(this); statisticsChartPanel.setLegendPosition(LegendPosition.TOP); statisticsChartPanel.setChartWidth(500); horizontalPanel.add(statisticsChartPanel); horizontalPanel.setSpacing(10); add(horizontalPanel); // GRBK-874 instructionLabel = new Label(i18n.gradeScaleInstructions()); instructionLabel.addStyleName(resources.css().gradeScaleInstructions()); add(instructionLabel); addButton(resetToDefaultButton); addButton(closeButton); // GRBK-959 setScrollMode(Scroll.AUTO); }
From source file:org.sakaiproject.gradebook.gwt.client.gxt.view.panel.StatisticsPanel.java
License:Educational Community License
public StatisticsPanel(final I18nConstants i18n) { super();/*from w ww. jav a 2s . c om*/ // Getting needed resources this.i18n = i18n; // Configure main ContentPanel setHeading(i18n.statisticsHeading()); setFrame(true); setBodyBorder(true); setButtonAlign(HorizontalAlignment.RIGHT); setBodyStyle("padding: 10px"); setScrollMode(Scroll.AUTO); sectionsComboBox = new SectionsComboBox<ModelData>(); sectionsComboBox.setStyleAttribute("padding-left", "10px"); sectionsComboBox.addSelectionChangedListener(new SelectionChangedListener<ModelData>() { public void selectionChanged(SelectionChangedEvent<ModelData> se) { statisticsChartPanel.hide(); grid.getStore().removeAll(); grid.getStore().getLoader().load(); selectedGradeItemRow = -1; } }); // Adding the combobox add(sectionsComboBox); // Adding the instructions on how to show a chart Text instructions = new Text(i18n.statisticsGraphInstructions()); instructions.setStyleAttribute("padding", "10px"); add(instructions); // Creating the grade item statistics grid grid = getGrid(); // Creating the chart panel and initially hide it statisticsChartPanel = new StatisticsChartPanel(); statisticsChartPanel.setLegendPosition(LegendPosition.TOP); statisticsChartPanel.setSize(AppConstants.CHART_WIDTH, AppConstants.CHART_HEIGHT + 80); statisticsChartPanel.hide(); gridAndChartHorizontalPanel = new HorizontalPanel(); gridAndChartHorizontalPanel.setSpacing(10); gridAndChartHorizontalPanel.add(grid); gridAndChartHorizontalPanel.add(statisticsChartPanel); add(gridAndChartHorizontalPanel); // Creating the close button to the ContentPanel Button closeButton = new AriaButton(i18n.close(), new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent be) { Dispatcher.forwardEvent(GradebookEvents.StopStatistics.getEventType(), Boolean.FALSE); // Hide the chart panel statisticsChartPanel.hide(); // Reset the last selected grade item row selectedGradeItemRow = -1; // Clearing the data table cache dataTableCache.clear(); // Reset the section selection sectionsComboBox.reset(); } }); addButton(closeButton); }
From source file:org.sakaiproject.gradebook.gwt.client.gxt.view.panel.StudentPanel.java
License:Educational Community License
public StudentPanel(I18nConstants i18n, boolean isStudentView, boolean displayRank) { super();//from w w w . j a v a2 s. co m this.isStudentView = isStudentView; this.defaultTextArea.addInputStyleName(resources.css().gbTextAreaInput()); this.defaultTextField.addInputStyleName(resources.css().gbTextFieldInput()); this.displayRank = displayRank; applicationSetup = Registry.get(AppConstants.APP_MODEL); setFrame(true); setHeaderVisible(false); setLayout(new FlowLayout()); setScrollMode(Scroll.AUTO); studentInformation = new FlexTable(); studentInformation.setStyleName(resources.css().gbStudentInformation()); studentInformationPanel = new ContentPanel(); studentInformationPanel.setBorders(false); studentInformationPanel.setFrame(true); studentInformationPanel.setHeaderVisible(false); // Make it the same height as the chart studentInformationPanel.setHeight(AppConstants.CHART_HEIGHT); studentInformationPanel.setWidth(510); studentInformationPanel.setLayout(new FitLayout()); studentInformationPanel.setStyleName(resources.css().gbStudentInformationPanel()); studentInformationPanel.add(studentInformation); statisticsChartPanel = new StatisticsChartPanel(ChartIconPlacement.RIGHT, applicationSetup.getCachedDataAge()); statisticsChartPanel.setLegendPosition(LegendPosition.TOP); statisticsChartPanel.setSize(AppConstants.CHART_WIDTH, AppConstants.CHART_HEIGHT); statisticsChartPanel.setChartHeight(AppConstants.CHART_HEIGHT - 50); statisticsChartPanel.setChartWidth(AppConstants.CHART_WIDTH - 50); statisticsChartPanel.setStyleName(resources.css().gbStudentChart()); statisticsChartPanel.setWidth(610); // Initially, we mask and hide the statistics chart panel statisticsChartPanel.mask(); statisticsChartPanel.hide(); topPanel = new HorizontalPanel(); topPanel.add(studentInformationPanel); topPanel.add(statisticsChartPanel); add(topPanel); store = new GroupingStore<BaseModel>(); store.setGroupOnSort(false); store.setSortField(Key.S_ORDER.name()); store.setSortDir(Style.SortDir.ASC); store.setModelComparer(new ModelComparer<BaseModel>() { public boolean equals(BaseModel m1, BaseModel m2) { if (m1 == null || m2 == null) return false; String id1 = m1.get(Key.S_ID.name()); String id2 = m2.get(Key.S_ID.name()); if (id1 != null && id2 != null) { return id1.equals(id2); } return false; } }); store.setStoreSorter(new StoreSorter<BaseModel>() { public int compare(Store<BaseModel> store, BaseModel m1, BaseModel m2, String property) { if (property != null) { // We do not want the sort by category to take if (property.equals(Key.S_CTGRY_NM.name())) return 0; if (property.equals(Key.S_ITM_NM.name())) property = ItemKey.I_SRT_ORDR.name(); //property = Key.S_ORDER.name(); Object v1 = m1.get(property); Object v2 = m2.get(property); return comparator.compare(v1, v2); } return comparator.compare(m1, m2); } }); loader = RestBuilder.getDelayLoader(AppConstants.LIST_ROOT, EnumSet.allOf(StatisticsKey.class), Method.GET, new UrlArgsCallback() { public String getUrlArg() { String uid = learnerGradeRecordCollection.get(LearnerKey.S_UID.name()); return Base64.encode(uid); } }, new NewModelCallback() { public ModelData newModelInstance(EntityOverlay overlay) { return new StatisticsModel(overlay); } }, GWT.getModuleBaseURL(), AppConstants.REST_FRAGMENT, AppConstants.STATISTICS_FRAGMENT); loader.addLoadListener(new LoadListener() { public void loaderLoad(LoadEvent event) { BaseListLoadResult<Statistics> result = event.getData(); statsList = result.getData(); refreshGradeData(learnerGradeRecordCollection, statsList); isPossibleStatsChanged = false; /* * GRBK-1117 : Making sure that the grid gets refreshed after the loader has finished loading. * This fixes the issue where the vertical scroll bar doesn't allow to scroll to the * last row in the grid. The layout() method fixes the grid's height. */ grid.getView().layout(); } }); ArrayList<ColumnConfig> columns = new ArrayList<ColumnConfig>(); categoryColumn = new ColumnConfig(Key.S_CTGRY_NM.name(), i18n.categoryName(), 250); categoryColumn.setGroupable(true); categoryColumn.setHidden(true); categoryColumn.setMenuDisabled(true); columns.add(categoryColumn); ColumnConfig column = new ColumnConfig(Key.S_ITM_NM.name(), i18n.itemName(), 160); column.setGroupable(false); column.setMenuDisabled(true); columns.add(column); weightColumn = new ColumnConfig(Key.S_ITM_WGHT.name(), i18n.weightName(), 90); weightColumn.setGroupable(false); weightColumn.setMenuDisabled(true); columns.add(weightColumn); column = new ColumnConfig(Key.S_GRD.name(), i18n.scoreName(), 60); column.setGroupable(false); column.setMenuDisabled(true); column.setRenderer(new GridCellRenderer<ModelData>() { public Object render(ModelData model, String property, com.extjs.gxt.ui.client.widget.grid.ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) { if (DataTypeConversionUtil.checkBoolean((Boolean) model.get(Key.B_DROPPED.name()))) { return new StringBuilder().append("<span class=\"").append(resources.css().gbCellDropped()) .append("\">").append(model.get(property)).append("</span>"); } return model.get(property); } }); columns.add(column); outOfColumn = new ColumnConfig(Key.S_OUTOF.name(), i18n.outOfName(), 60); outOfColumn.setGroupable(false); outOfColumn.setMenuDisabled(true); columns.add(outOfColumn); dateDueColumn = new ColumnConfig(Key.T_DATEDUE.name(), i18n.dateDueName(), 90); dateDueColumn.setGroupable(false); dateDueColumn.setDateTimeFormat(DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT)); dateDueColumn.setMenuDisabled(true); columns.add(dateDueColumn); meanColumn = new ColumnConfig(Key.S_MEAN.name(), i18n.meanName(), 60); meanColumn.setGroupable(false); meanColumn.setMenuDisabled(true); meanColumn.setHidden(true); columns.add(meanColumn); stdvColumn = new ColumnConfig(Key.S_STDV.name(), i18n.stdvName(), 60); stdvColumn.setGroupable(false); stdvColumn.setMenuDisabled(true); stdvColumn.setHidden(true); columns.add(stdvColumn); medianColumn = new ColumnConfig(Key.S_MEDI.name(), i18n.medianName(), 60); medianColumn.setGroupable(false); medianColumn.setMenuDisabled(true); medianColumn.setHidden(true); columns.add(medianColumn); modeColumn = new ColumnConfig(Key.S_MODE.name(), i18n.modeName(), 150); modeColumn.setGroupable(false); modeColumn.setMenuDisabled(true); modeColumn.setHidden(true); columns.add(modeColumn); hasCommentColumn = new ColumnConfig(Key.S_HAS_COMMENT.name(), i18n.hasCommentName(), 80); hasCommentColumn.setGroupable(false); hasCommentColumn.setMenuDisabled(true); hasCommentColumn.setHidden(false); hasCommentColumn.setAlignment(HorizontalAlignment.CENTER); hasCommentColumn.setRenderer(new GridCellRenderer<ModelData>() { public Object render(ModelData model, String property, com.extjs.gxt.ui.client.widget.grid.ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) { Boolean hasComment = (Boolean) model.get(property); if (null != hasComment && hasComment) { hasCommentIcon = new Image(resources.comment()); hasCommentIcon.setStyleName(resources.css().commentIcon()); return hasCommentIcon; } else { return new String(""); } } }); columns.add(hasCommentColumn); cm = new ColumnModel(columns); selectionModel = new GridSelectionModel<BaseModel>(); selectionModel.setSelectionMode(SelectionMode.SINGLE); selectionModel.addSelectionChangedListener(new SelectionChangedListener<BaseModel>() { @Override public void selectionChanged(SelectionChangedEvent<BaseModel> sce) { // Check if user selected show statistics chart BaseModel score = sce.getSelectedItem(); if (score != null) { // Don't show the comments form if the user clicks on the Course Grade item if (COURSE_GRADE_ID.equals(score.get(Key.S_ID.name()))) { commentsPanel.hide(); /* * Only show statistics charts if the user checked the * "Statistics Chart" option in the "Set Up Gradebook" page */ if (showStatisticsChart()) { getCourseStatisticsChartData(); } } else { /* * Only show statistics charts if the user checked the * "Statistics Chart" option in the "Set Up Gradebook" page */ if (showStatisticsChart()) { getGradeItemStatisticsChartData((String) score.get(Key.S_ITM_ID.name())); } formBinding.bind(score); commentsPanel.show(); } } else { commentsPanel.hide(); formBinding.unbind(); } } }); GroupingView view = new GroupingView(); grid = new Grid<BaseModel>(store, cm); grid.setBorders(true); grid.setSelectionModel(selectionModel); grid.setView(view); grid.setWidth(810); grid.setHeight(360); gradeInformationContentPanel = new ContentPanel(); // NOTE: The header is set in the setGradeInfoTable() method gradeInformationContentPanel.setBorders(true); gradeInformationContentPanel.setFrame(true); gradeInformationContentPanel.setWidth(1120); gradeInformationContentPanel.setHeight(400); gradeInformationContentPanel.hide(); gradeInformationPanel = new HorizontalPanel(); gradeInformationPanel.add(grid); FormLayout commentLayout = new FormLayout(); commentLayout.setLabelAlign(LabelAlign.TOP); commentLayout.setDefaultWidth(280); commentsPanel = new FormPanel(); commentsPanel.setHeaderVisible(false); commentsPanel.setLayout(commentLayout); commentsPanel.setVisible(false); commentsPanel.setWidth(300); commentsPanel.setHeight(360); commentArea = new TextArea(); commentArea.setName(Key.S_COMMENT.name()); commentArea.setFieldLabel(i18n.commentName()); commentArea.setWidth(275); commentArea.setHeight(325); commentArea.setReadOnly(true); commentsPanel.add(commentArea); gradeInformationPanel.add(commentsPanel); formBinding = new FormBinding(commentsPanel, true); textPanel = new ContentPanel(); textPanel.setBorders(true); textPanel.setFrame(true); textPanel.setHeaderVisible(false); textPanel.setWidth(505); textPanel.hide(); textNotification = textPanel.addText(""); gradeInformationContentPanel.add(gradeInformationPanel); add(textPanel); add(gradeInformationContentPanel); }