List of usage examples for com.vaadin.ui VerticalLayout setWidth
@Override public void setWidth(float width, Unit unit)
From source file:org.opennms.features.vaadin.dashboard.dashlets.RrdDashlet.java
License:Open Source License
/** * Returns the graph component for a given graph of the {@link DashletSpec}. * * @param i the entry id//w ww .j a v a 2 s .c om * @param width the width * @param height the height * @param timeFrameType the timeframe type * @param timeFrameValue the timeframe value * @return the component */ private Component getGraphComponent(int i, int width, int height, int timeFrameType, int timeFrameValue) { String graphTitle = getDashletSpec().getParameters().get("graphLabel" + i); String graphName = RrdGraphHelper .getGraphNameFromQuery(getDashletSpec().getParameters().get("graphUrl" + i)); String resourceId = getDashletSpec().getParameters().get("resourceId" + i); GraphContainer graph = new GraphContainer(graphName, resourceId); graph.setTitle(graphTitle); // Setup the time span Calendar cal = new GregorianCalendar(); graph.setEnd(cal.getTime()); cal.add(timeFrameType, -timeFrameValue); graph.setStart(cal.getTime()); // Use all of the available width graph.setWidthRatio(1.0d); VerticalLayout verticalLayout = new VerticalLayout(); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.addStyleName("box"); horizontalLayout.setWidth("100%"); horizontalLayout.setHeight("42px"); VerticalLayout leftLayout = new VerticalLayout(); leftLayout.setDefaultComponentAlignment(Alignment.TOP_LEFT); leftLayout.addStyleName("margin"); Label labelFrom = new Label(getDashletSpec().getParameters().get("nodeLabel" + i)); labelFrom.addStyleName("text"); Label labelTo = new Label(getDashletSpec().getParameters().get("resourceTypeLabel" + i) + ": " + getDashletSpec().getParameters().get("resourceLabel" + i)); labelTo.addStyleName("text"); leftLayout.addComponent(labelFrom); leftLayout.addComponent(labelTo); horizontalLayout.addComponent(leftLayout); horizontalLayout.setExpandRatio(leftLayout, 1.0f); verticalLayout.addComponent(horizontalLayout); verticalLayout.addComponent(graph); verticalLayout.setWidth(width, Unit.PIXELS); verticalLayout.setComponentAlignment(horizontalLayout, Alignment.MIDDLE_CENTER); verticalLayout.setComponentAlignment(graph, Alignment.MIDDLE_CENTER); verticalLayout.setMargin(true); return verticalLayout; }
From source file:org.opennms.features.vaadin.dashboard.dashlets.RrdGraphEntry.java
License:Open Source License
/** * Constrcutor for creating new instances of this class. * * @param nodeDao the node dao instance to be used * @param rrdGraphHelper the rrd graph helper instancce to be used * @param x the x-position of this entry * @param y the y-position of this entry *//* w ww .j a va 2 s .c o m*/ public RrdGraphEntry(final NodeDao nodeDao, final RrdGraphHelper rrdGraphHelper, int x, int y) { /** * setting the member fields */ this.m_x = x; this.m_y = y; /** * setting up the buttons */ m_changeButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { GraphSelectionWindow graphSelectionWindow = new GraphSelectionWindow(nodeDao, rrdGraphHelper, RrdGraphEntry.this); getUI().addWindow(graphSelectionWindow); } }); m_removeButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { setGraphId(null); setGraphLabel(null); setGraphUrl(null); setNodeId(null); setNodeLabel(null); setResourceId(null); setResourceLabel(null); setResourceTypeId(null); setResourceTypeLabel(null); update(); } }); m_removeButton.addStyleName(BaseTheme.BUTTON_LINK); m_changeButton.addStyleName(BaseTheme.BUTTON_LINK); /** * setting up the layout */ VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); m_graphLayout.setSizeUndefined(); m_graphLayout.setWidth(200, Unit.PIXELS); m_graphLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); /** * adding the components */ verticalLayout.addComponent(m_nodeLabelComponent); verticalLayout.addComponent(m_graphLabelComponent); verticalLayout.addComponent(m_changeButton); verticalLayout.addComponent(m_removeButton); verticalLayout.addComponent(m_graphLayout); m_nodeLabelComponent.setSizeUndefined(); m_graphLabelComponent.setSizeUndefined(); verticalLayout.setWidth(100, Unit.PERCENTAGE); setSizeFull(); /** * inject the preview style */ Page.getCurrent().getStyles().add(".preview { width:175px; }"); /** * initial update */ update(); /** * setting the content */ setContent(verticalLayout); }
From source file:org.opennms.features.vaadin.dashboard.dashlets.SummaryDashlet.java
License:Open Source License
/** * Returns the component showing the alarms and the trends by severity * * @return the {@link Component}/*from w w w .j a v a 2 s. co m*/ */ private Component getComponentSeverity(int width) { VerticalLayout verticalLayout = new VerticalLayout(); int overallSum = 0; int severitySum = 0; verticalLayout.addComponent(getLegend("Severity")); for (OnmsSeverity onmsSeverity : OnmsSeverity.values()) { HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setSpacing(true); horizontalLayout.addStyleName("summary"); horizontalLayout.addStyleName(onmsSeverity.name().toLowerCase()); int acknowledged = countBySeverity(true, m_timeslot, onmsSeverity); int notAcknowledged = countBySeverity(false, m_timeslot, onmsSeverity); Label labelSeverity = new Label(onmsSeverity.getLabel()); labelSeverity.addStyleName("summary-font"); Label labelAcknowledge = new Label(String.valueOf(acknowledged)); labelAcknowledge.addStyleName("summary-font"); Label labelNotAcknowledged = new Label(String.valueOf(notAcknowledged)); labelNotAcknowledged.addStyleName("summary-font"); horizontalLayout.addComponent(labelSeverity); horizontalLayout.addComponent(labelAcknowledge); horizontalLayout.addComponent(labelNotAcknowledged); int status = computeTrend(acknowledged, notAcknowledged); severitySum += onmsSeverity.getId(); overallSum += onmsSeverity.getId() * status; Image image = new Image(null, new ThemeResource("img/a" + status + ".png")); image.setWidth(width, Sizeable.Unit.PIXELS); horizontalLayout.addComponent(image); horizontalLayout.setExpandRatio(labelSeverity, 4.0f); horizontalLayout.setExpandRatio(labelAcknowledge, 1.0f); horizontalLayout.setExpandRatio(labelNotAcknowledged, 1.0f); horizontalLayout.setExpandRatio(image, 1.0f); horizontalLayout.setComponentAlignment(image, Alignment.TOP_CENTER); horizontalLayout.setWidth(375, Sizeable.Unit.PIXELS); verticalLayout.addComponent(horizontalLayout); } int globalTrend = (int) Math.max(0, Math.min(4, Math.round(((double) overallSum) / ((double) severitySum)))); Image image = new Image(null, new ThemeResource("img/a" + globalTrend + ".png")); image.setWidth(width * 8, Sizeable.Unit.PIXELS); VerticalLayout globalTrendLayout = new VerticalLayout(); globalTrendLayout.setSpacing(true); globalTrendLayout.addStyleName("summary"); globalTrendLayout.addStyleName("global"); globalTrendLayout.setSizeFull(); Label labelTitle = new Label("Alarms trend by severity"); labelTitle.addStyleName("summary-font"); labelTitle.setSizeUndefined(); Label labelTimeslot = new Label("(" + getHumanReadableFormat(m_timeslot) + ")"); labelTimeslot.addStyleName("summary-font"); labelTimeslot.setSizeUndefined(); globalTrendLayout.addComponent(labelTitle); globalTrendLayout.addComponent(labelTimeslot); globalTrendLayout.addComponent(image); globalTrendLayout.setWidth(375, Sizeable.Unit.PIXELS); globalTrendLayout.setComponentAlignment(labelTitle, Alignment.MIDDLE_CENTER); globalTrendLayout.setComponentAlignment(labelTimeslot, Alignment.MIDDLE_CENTER); globalTrendLayout.setComponentAlignment(image, Alignment.MIDDLE_CENTER); globalTrendLayout.setExpandRatio(labelTitle, 1.0f); verticalLayout.addComponent(globalTrendLayout, 0); m_boosted = (globalTrend > 2); return verticalLayout; }
From source file:org.opennms.features.vaadin.dashboard.dashlets.SummaryDashlet.java
License:Open Source License
/** * Returns the component showing the alarms and the trends by severity * * @return the {@link Component}/*ww w .j a v a 2 s.c o m*/ */ private Component getComponentUei(int width) { VerticalLayout verticalLayout = new VerticalLayout(); int overallSum = 0; int severitySum = 0; verticalLayout.addComponent(getLegend("UEI")); String[] ueis = { "uei.opennms.org/nodes/nodeLostService", "uei.opennms.org/nodes/interfaceDown", "uei.opennms.org/nodes/nodeDown" }; for (int i = 0; i < ueis.length; i++) { String uei = ueis[i]; HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setSpacing(true); horizontalLayout.addStyleName("summary"); if (i == 0) { horizontalLayout.addStyleName(OnmsSeverity.MINOR.name().toLowerCase()); } else { if (i == 1) { horizontalLayout.addStyleName(OnmsSeverity.MINOR.name().toLowerCase()); } else { horizontalLayout.addStyleName(OnmsSeverity.MAJOR.name().toLowerCase()); } } int acknowledged = countByUei(true, m_timeslot, uei); int notAcknowledged = countByUei(false, m_timeslot, uei); Label labelSeverity = new Label(uei.replace("uei.opennms.org/nodes/", "")); labelSeverity.addStyleName("summary-font"); Label labelAcknowledge = new Label(String.valueOf(acknowledged)); labelAcknowledge.addStyleName("summary-font"); Label labelNotAcknowledged = new Label(String.valueOf(notAcknowledged)); labelNotAcknowledged.addStyleName("summary-font"); horizontalLayout.addComponent(labelSeverity); horizontalLayout.addComponent(labelAcknowledge); horizontalLayout.addComponent(labelNotAcknowledged); int status = computeTrend(acknowledged, notAcknowledged); severitySum += i; overallSum += i * status; Image image = new Image(null, new ThemeResource("img/a" + status + ".png")); image.setWidth(width, Sizeable.Unit.PIXELS); horizontalLayout.addComponent(image); horizontalLayout.setExpandRatio(labelSeverity, 4.0f); horizontalLayout.setExpandRatio(labelAcknowledge, 1.0f); horizontalLayout.setExpandRatio(labelNotAcknowledged, 1.0f); horizontalLayout.setExpandRatio(image, 1.0f); horizontalLayout.setComponentAlignment(image, Alignment.TOP_CENTER); horizontalLayout.setWidth(375, Sizeable.Unit.PIXELS); verticalLayout.addComponent(horizontalLayout); } int globalTrend = (int) Math.max(0, Math.min(4, Math.round(((double) overallSum) / ((double) severitySum)))); Image image = new Image(null, new ThemeResource("img/a" + globalTrend + ".png")); image.setWidth(width * 8, Sizeable.Unit.PIXELS); VerticalLayout globalTrendLayout = new VerticalLayout(); globalTrendLayout.setSpacing(true); globalTrendLayout.addStyleName("summary"); globalTrendLayout.addStyleName("global"); globalTrendLayout.setSizeFull(); Label labelTitle = new Label("Alarms trend by UEI"); labelTitle.addStyleName("summary-font"); labelTitle.setSizeUndefined(); Label labelTimeslot = new Label("(" + getHumanReadableFormat(m_timeslot) + ")"); labelTimeslot.addStyleName("summary-font"); labelTimeslot.setSizeUndefined(); globalTrendLayout.addComponent(labelTitle); globalTrendLayout.addComponent(labelTimeslot); globalTrendLayout.addComponent(image); globalTrendLayout.setWidth(375, Sizeable.Unit.PIXELS); globalTrendLayout.setComponentAlignment(labelTitle, Alignment.MIDDLE_CENTER); globalTrendLayout.setComponentAlignment(labelTimeslot, Alignment.MIDDLE_CENTER); globalTrendLayout.setComponentAlignment(image, Alignment.MIDDLE_CENTER); globalTrendLayout.setExpandRatio(labelTitle, 1.0f); verticalLayout.addComponent(globalTrendLayout, 0); m_boosted = (globalTrend > 2); return verticalLayout; }
From source file:org.opennms.netmgt.bsm.vaadin.adminpage.BusinessServiceEditWindow.java
License:Open Source License
/** * Constructor/*from w w w. j a v a2s .com*/ * * @param businessService the Business Service DTO instance to be configured */ @SuppressWarnings("unchecked") public BusinessServiceEditWindow(BusinessService businessService, BusinessServiceManager businessServiceManager) { /** * set window title... */ super("Business Service Edit"); m_businessService = businessService; /** * ...and basic properties */ setModal(true); setClosable(false); setResizable(false); setWidth(650, Unit.PIXELS); setHeight(550, Unit.PIXELS); /** * create set for Business Service names */ m_businessServiceNames = businessServiceManager.getAllBusinessServices().stream() .map(BusinessService::getName).collect(Collectors.toSet()); if (m_businessService.getName() != null) { m_businessServiceNames.remove(m_businessService.getName()); } /** * construct the main layout */ VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setSizeFull(); verticalLayout.setSpacing(true); verticalLayout.setMargin(true); /** * add saveBusinessService button */ Button saveButton = new Button("Save"); saveButton.setId("saveButton"); saveButton.addClickListener( UIHelper.getCurrent(TransactionAwareUI.class).wrapInTransactionProxy(new Button.ClickListener() { private static final long serialVersionUID = -5985304347211214365L; @Override public void buttonClick(Button.ClickEvent event) { if (!m_thresholdTextField.isValid() || !m_nameTextField.isValid()) { return; } final ReductionFunction reductionFunction = getReduceFunction(); businessService.setName(m_nameTextField.getValue().trim()); businessService.setReduceFunction(reductionFunction); businessService.save(); close(); } private ReductionFunction getReduceFunction() { try { final ReductionFunction reductionFunction = ((Class<? extends ReductionFunction>) m_reduceFunctionNativeSelect .getValue()).newInstance(); reductionFunction.accept(new ReduceFunctionVisitor<Void>() { @Override public Void visit(HighestSeverity highestSeverity) { return null; } @Override public Void visit(HighestSeverityAbove highestSeverityAbove) { highestSeverityAbove.setThreshold((Status) m_thresholdStatusSelect.getValue()); return null; } @Override public Void visit(Threshold threshold) { threshold.setThreshold(Float.parseFloat(m_thresholdTextField.getValue())); return null; } }); return reductionFunction; } catch (final InstantiationException | IllegalAccessException e) { throw Throwables.propagate(e); } } })); /** * add the cancel button */ Button cancelButton = new Button("Cancel"); cancelButton.setId("cancelButton"); cancelButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 5306168797758047745L; @Override public void buttonClick(Button.ClickEvent event) { close(); } }); /** * add the buttons to a HorizontalLayout */ HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); buttonLayout.addComponent(saveButton); buttonLayout.addComponent(cancelButton); /** * instantiate the input fields */ m_nameTextField = new TextField("Business Service Name"); m_nameTextField.setId("nameField"); m_nameTextField.setNullRepresentation(""); m_nameTextField.setNullSettingAllowed(true); m_nameTextField.setValue(businessService.getName()); m_nameTextField.setWidth(100, Unit.PERCENTAGE); m_nameTextField.setRequired(true); m_nameTextField.focus(); m_nameTextField.addValidator(new AbstractStringValidator("Name must be unique") { private static final long serialVersionUID = 1L; @Override protected boolean isValidValue(String value) { return value != null && !m_businessServiceNames.contains(value); } }); verticalLayout.addComponent(m_nameTextField); /** * create the reduce function component */ m_reduceFunctionNativeSelect = new NativeSelect("Reduce Function", ImmutableList.builder() .add(HighestSeverity.class).add(Threshold.class).add(HighestSeverityAbove.class).build()); m_reduceFunctionNativeSelect.setId("reduceFunctionNativeSelect"); m_reduceFunctionNativeSelect.setWidth(100.0f, Unit.PERCENTAGE); m_reduceFunctionNativeSelect.setNullSelectionAllowed(false); m_reduceFunctionNativeSelect.setMultiSelect(false); m_reduceFunctionNativeSelect.setImmediate(true); m_reduceFunctionNativeSelect.setNewItemsAllowed(false); /** * setting the captions for items */ m_reduceFunctionNativeSelect.getItemIds().forEach( itemId -> m_reduceFunctionNativeSelect.setItemCaption(itemId, ((Class<?>) itemId).getSimpleName())); verticalLayout.addComponent(m_reduceFunctionNativeSelect); m_thresholdTextField = new TextField("Threshold"); m_thresholdTextField.setId("thresholdTextField"); m_thresholdTextField.setRequired(false); m_thresholdTextField.setEnabled(false); m_thresholdTextField.setImmediate(true); m_thresholdTextField.setWidth(100.0f, Unit.PERCENTAGE); m_thresholdTextField.setValue("0.0"); m_thresholdTextField.addValidator(v -> { if (m_thresholdTextField.isEnabled()) { try { final float value = Float.parseFloat(m_thresholdTextField.getValue()); if (0.0f >= value || value > 1.0) { throw new NumberFormatException(); } } catch (final NumberFormatException e) { throw new Validator.InvalidValueException("Threshold must be a positive number"); } } }); verticalLayout.addComponent(m_thresholdTextField); /** * Status selection for "Highest Severity Above" */ m_thresholdStatusSelect = new NativeSelect("Threshold"); m_thresholdStatusSelect.setId("thresholdStatusSelect"); m_thresholdStatusSelect.setRequired(false); m_thresholdStatusSelect.setEnabled(false); m_thresholdStatusSelect.setImmediate(true); m_thresholdStatusSelect.setWidth(100.0f, Unit.PERCENTAGE); m_thresholdStatusSelect.setMultiSelect(false); m_thresholdStatusSelect.setNewItemsAllowed(false); m_thresholdStatusSelect.setNullSelectionAllowed(false); for (Status eachStatus : Status.values()) { m_thresholdStatusSelect.addItem(eachStatus); } m_thresholdStatusSelect.setValue(Status.INDETERMINATE); m_thresholdStatusSelect.getItemIds() .forEach(itemId -> m_thresholdStatusSelect.setItemCaption(itemId, ((Status) itemId).getLabel())); verticalLayout.addComponent(m_thresholdStatusSelect); m_reduceFunctionNativeSelect.addValueChangeListener(ev -> { boolean thresholdFunction = m_reduceFunctionNativeSelect.getValue() == Threshold.class; boolean highestSeverityAboveFunction = m_reduceFunctionNativeSelect .getValue() == HighestSeverityAbove.class; setVisible(m_thresholdTextField, thresholdFunction); setVisible(m_thresholdStatusSelect, highestSeverityAboveFunction); }); if (Objects.isNull(businessService.getReduceFunction())) { m_reduceFunctionNativeSelect.setValue(HighestSeverity.class); } else { m_reduceFunctionNativeSelect.setValue(businessService.getReduceFunction().getClass()); businessService.getReduceFunction().accept(new ReduceFunctionVisitor<Void>() { @Override public Void visit(HighestSeverity highestSeverity) { return null; } @Override public Void visit(HighestSeverityAbove highestSeverityAbove) { m_thresholdStatusSelect.setValue(highestSeverityAbove.getThreshold()); return null; } @Override public Void visit(Threshold threshold) { m_thresholdTextField.setValue(String.valueOf(threshold.getThreshold())); return null; } }); } /** * create the edges list box */ m_edgesListSelect = new ListSelect("Edges"); m_edgesListSelect.setId("edgeList"); m_edgesListSelect.setWidth(100.0f, Unit.PERCENTAGE); m_edgesListSelect.setRows(10); m_edgesListSelect.setNullSelectionAllowed(false); m_edgesListSelect.setMultiSelect(false); refreshEdges(); HorizontalLayout edgesListAndButtonLayout = new HorizontalLayout(); edgesListAndButtonLayout.setWidth(100.0f, Unit.PERCENTAGE); VerticalLayout edgesButtonLayout = new VerticalLayout(); edgesButtonLayout.setWidth(110.0f, Unit.PIXELS); edgesButtonLayout.setSpacing(true); Button addEdgeButton = new Button("Add Edge"); addEdgeButton.setId("addEdgeButton"); addEdgeButton.setWidth(110.0f, Unit.PIXELS); addEdgeButton.addStyleName("small"); edgesButtonLayout.addComponent(addEdgeButton); addEdgeButton.addClickListener((Button.ClickListener) event -> { final BusinessServiceEdgeEditWindow window = new BusinessServiceEdgeEditWindow(businessService, businessServiceManager, null); window.addCloseListener(e -> refreshEdges()); this.getUI().addWindow(window); }); Button editEdgeButton = new Button("Edit Edge"); editEdgeButton.setId("editEdgeButton"); editEdgeButton.setEnabled(false); editEdgeButton.setWidth(110.0f, Unit.PIXELS); editEdgeButton.addStyleName("small"); edgesButtonLayout.addComponent(editEdgeButton); editEdgeButton.addClickListener((Button.ClickListener) event -> { final BusinessServiceEdgeEditWindow window = new BusinessServiceEdgeEditWindow(businessService, businessServiceManager, (Edge) m_edgesListSelect.getValue()); window.addCloseListener(e -> refreshEdges()); this.getUI().addWindow(window); }); final Button removeEdgeButton = new Button("Remove Edge"); removeEdgeButton.setId("removeEdgeButton"); removeEdgeButton.setEnabled(false); removeEdgeButton.setWidth(110.0f, Unit.PIXELS); removeEdgeButton.addStyleName("small"); edgesButtonLayout.addComponent(removeEdgeButton); m_edgesListSelect.addValueChangeListener((Property.ValueChangeListener) event -> { removeEdgeButton.setEnabled(event.getProperty().getValue() != null); editEdgeButton.setEnabled(event.getProperty().getValue() != null); }); removeEdgeButton.addClickListener((Button.ClickListener) event -> { if (m_edgesListSelect.getValue() != null) { removeEdgeButton.setEnabled(false); ((Edge) m_edgesListSelect.getValue()).delete(); refreshEdges(); } }); edgesListAndButtonLayout.setSpacing(true); edgesListAndButtonLayout.addComponent(m_edgesListSelect); edgesListAndButtonLayout.setExpandRatio(m_edgesListSelect, 1.0f); edgesListAndButtonLayout.addComponent(edgesButtonLayout); edgesListAndButtonLayout.setComponentAlignment(edgesButtonLayout, Alignment.BOTTOM_CENTER); verticalLayout.addComponent(edgesListAndButtonLayout); /** * create the attributes list box */ m_attributesListSelect = new ListSelect("Attributes"); m_attributesListSelect.setId("attributeList"); m_attributesListSelect.setWidth(100.0f, Unit.PERCENTAGE); m_attributesListSelect.setRows(10); m_attributesListSelect.setNullSelectionAllowed(false); m_attributesListSelect.setMultiSelect(false); refreshAttributes(); HorizontalLayout attributesListAndButtonLayout = new HorizontalLayout(); attributesListAndButtonLayout.setWidth(100.0f, Unit.PERCENTAGE); VerticalLayout attributesButtonLayout = new VerticalLayout(); attributesButtonLayout.setWidth(110.0f, Unit.PIXELS); attributesButtonLayout.setSpacing(true); Button addAttributeButton = new Button("Add Attribute"); addAttributeButton.setId("addAttributeButton"); addAttributeButton.setWidth(110.0f, Unit.PIXELS); addAttributeButton.addStyleName("small"); attributesButtonLayout.addComponent(addAttributeButton); addAttributeButton.addClickListener((Button.ClickListener) event -> { KeyValueInputDialogWindow keyValueInputDialogWindow = new KeyValueInputDialogWindow() .withKeyFieldName("Key").withValueFieldName("Value").withCaption("Attribute").withKey("") .withValue("").withOkAction(new KeyValueInputDialogWindow.Action() { @Override public void execute(KeyValueInputDialogWindow window) { m_businessService.getAttributes().put(window.getKey(), window.getValue()); refreshAttributes(); } }).withKeyValidator(new AbstractStringValidator("Key must not be empty") { private static final long serialVersionUID = 1L; @Override protected boolean isValidValue(String value) { return !Strings.isNullOrEmpty(value); } }).withKeyValidator(new AbstractStringValidator("Key must be unique") { private static final long serialVersionUID = 1L; @Override protected boolean isValidValue(String value) { return !m_businessService.getAttributes().containsKey(value); } }).focusKey(); this.getUI().addWindow(keyValueInputDialogWindow); keyValueInputDialogWindow.focus(); }); Button editAttributeButton = new Button("Edit Attribute"); editAttributeButton.setId("editAttributeButton"); editAttributeButton.setEnabled(false); editAttributeButton.setWidth(110.0f, Unit.PIXELS); editAttributeButton.addStyleName("small"); attributesButtonLayout.addComponent(editAttributeButton); editAttributeButton.addClickListener((Button.ClickListener) event -> { Map.Entry<String, String> entry = (Map.Entry<String, String>) m_attributesListSelect.getValue(); KeyValueInputDialogWindow keyValueInputDialogWindow = new KeyValueInputDialogWindow() .withKeyFieldName("Key").withValueFieldName("Value").withCaption("Attribute") .withKey(entry.getKey()).disableKey().withValue(entry.getValue()) .withOkAction(new KeyValueInputDialogWindow.Action() { @Override public void execute(KeyValueInputDialogWindow window) { m_businessService.getAttributes().put(window.getKey(), window.getValue()); refreshAttributes(); } }).focusValue(); this.getUI().addWindow(keyValueInputDialogWindow); keyValueInputDialogWindow.focus(); }); final Button removeAttributeButton = new Button("Remove Attribute"); removeAttributeButton.setId("removeAttributeButton"); removeAttributeButton.setEnabled(false); removeAttributeButton.setWidth(110.0f, Unit.PIXELS); removeAttributeButton.addStyleName("small"); attributesButtonLayout.addComponent(removeAttributeButton); m_attributesListSelect.addValueChangeListener((Property.ValueChangeListener) event -> { removeAttributeButton.setEnabled(event.getProperty().getValue() != null); editAttributeButton.setEnabled(event.getProperty().getValue() != null); }); removeAttributeButton.addClickListener((Button.ClickListener) event -> { if (m_attributesListSelect.getValue() != null) { removeAttributeButton.setEnabled(false); m_businessService.getAttributes() .remove(((Map.Entry<String, String>) m_attributesListSelect.getValue()).getKey()); refreshAttributes(); } }); attributesListAndButtonLayout.setSpacing(true); attributesListAndButtonLayout.addComponent(m_attributesListSelect); attributesListAndButtonLayout.setExpandRatio(m_attributesListSelect, 1.0f); attributesListAndButtonLayout.addComponent(attributesButtonLayout); attributesListAndButtonLayout.setComponentAlignment(attributesButtonLayout, Alignment.BOTTOM_CENTER); verticalLayout.addComponent(attributesListAndButtonLayout); /** * now add the button layout to the main layout */ verticalLayout.addComponent(buttonLayout); verticalLayout.setExpandRatio(buttonLayout, 1.0f); verticalLayout.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT); /** * set the window's content */ setContent(verticalLayout); }
From source file:org.sensorhub.ui.DefaultModulePanelBuilder.java
License:Mozilla Public License
@Override public Component buildPanel(MyBeanItem<ModuleConfig> beanItem, IModule<?> module, IModuleConfigFormBuilder formBuilder) { // create panel with module name String moduleType = formBuilder.getTitle(beanItem.getBean()); Panel panel = new Panel(moduleType); // add generated form VerticalLayout layout = new VerticalLayout(); layout.setSizeUndefined();/*from www .j a va 2 s . c o m*/ layout.setWidth(100.0f, Unit.PERCENTAGE); layout.setMargin(true); Component form = formBuilder.buildForm(new FieldGroup(beanItem)); layout.addComponent(form); panel.setContent(layout); return panel; }
From source file:org.vaadin.addons.core.window.DialogWindow.java
License:Apache License
private VerticalLayout buildContent(String title, VaadinIcons type, Component content, ButtonType[] buttonTypes) {/*from w w w .j a va 2 s . c o m*/ VerticalLayout root = new VerticalLayout(); root.setMargin(false); root.setSpacing(false); float width = -1; float height = 0; if (title != null) { HorizontalLayout header = new HorizontalLayout(); header.setMargin(true); header.setHeightUndefined(); header.setWidth("100%"); header.addStyleName(ValoTheme.WINDOW_TOP_TOOLBAR); Label l = new Label("<font size=\"4\">" + title + "</font>", ContentMode.HTML); width = l.getWidth(); header.addComponent(l); header.setComponentAlignment(l, Alignment.MIDDLE_LEFT); if (type != null) { Label i = new Label(type.getHtml(), ContentMode.HTML); header.addComponent(i); header.setComponentAlignment(i, Alignment.MIDDLE_RIGHT); } height = header.getHeight(); root.addComponent(header); } if (content != null) { content.setSizeFull(); HorizontalLayout contentRoot = new HorizontalLayout(content); contentRoot.setMargin(true); root.addComponent(contentRoot); height = height + contentRoot.getHeight(); } HorizontalLayout footer = new HorizontalLayout(); footer.setHeightUndefined(); footer.setWidth("100%"); footer.setMargin(true); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); HorizontalLayout buttons = new HorizontalLayout(); if (buttonTypes != null) { Stream.of(buttonTypes).forEach(buttonType -> { Button b = new Button(buttonType.getCaption()); if (buttonType.getIcon() != null) { b.setIcon(buttonType.getIcon()); } if (buttonType.getDescription() != null) { b.setDescription(buttonType.getDescription()); } if (buttonType.getStyle() != null) { b.addStyleName(buttonType.getStyle()); } b.addClickListener(event -> buttonType.getActions().forEach(buttonAction -> { ButtonTypeClickEvent event1 = new ButtonTypeClickEvent(buttonType, DialogWindow.this); buttonAction.getListener().buttonClick(event1); })); buttons.addComponent(b); }); } buttons.setSizeUndefined(); buttons.setMargin(false); buttons.setSpacing(true); footer.addComponent(buttons); footer.setComponentAlignment(buttons, Alignment.MIDDLE_RIGHT); if (buttons.getWidth() > width) { width = buttons.getWidth(); } root.addComponent(footer); root.setComponentAlignment(footer, Alignment.BOTTOM_LEFT); height = height + footer.getHeight(); root.setHeight(height, Unit.PIXELS); root.setWidth(width, Unit.PIXELS); return root; }
From source file:org.vaadin.alump.scaleimage.demo.DemoUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { VerticalLayout layout = new VerticalLayout(); layout.setWidth(100, Unit.PERCENTAGE); layout.setMargin(true);/* w ww . j a v a 2s . c om*/ layout.setSpacing(true); setContent(layout); // Big image that will scale to match with your page width, will // show the center of given picture. See SCSS file. ScaleImage bigCenterImage = new ScaleImage(); bigCenterImage.setWidth("100%"); bigCenterImage.setHeight("200px"); bigCenterImage.setStyleName("big-center-image"); bigCenterImage.setSource(new ThemeResource("images/big-center-image.jpg")); bigCenterImage.addClickListener(new MouseEvents.ClickListener() { @Override public void click(MouseEvents.ClickEvent clickEvent) { Notification.show("Big center image clicked!"); } }); layout.addComponent(bigCenterImage); // Tile with image, where images will be scaled to match with tile size. // tileimage will cover space of tile and indicator image will be at // top left corner. // Uses absolute left/right/top/down positioning. See SCSS file. final CssLayout tile = new CssLayout(); tile.setStyleName("tile"); tile.setWidth(100, Unit.PIXELS); tile.setHeight(100, Unit.PIXELS); layout.addComponent(tile); tile.addLayoutClickListener(new LayoutClickListener() { @Override public void layoutClick(LayoutClickEvent event) { int size = (int) Math.round(100.0 + Math.random() * 100.0); tile.setWidth(size, Unit.PIXELS); tile.setHeight(size, Unit.PIXELS); } }); ScaleImage tileImage = new ScaleImage(); tileImage.setSource(new ThemeResource("images/tile-image.jpg")); tileImage.setStyleName("tile-image"); tile.addComponent(tileImage); ScaleImage indicatorImage = new ScaleImage(); indicatorImage.setSource(new ThemeResource("images/tile-indicator.png")); indicatorImage.setStyleName("tile-indicator"); tile.addComponent(indicatorImage); Label tileLabel = new Label("Click tile to scale it."); tile.addComponent(tileLabel); extendedImage = new ExtendedScaleImage(); extendedImage.setSource(new ThemeResource("images/tile-indicator.png")); extendedImage.setWidth("200px"); extendedImage.setHeight("400px"); extendedImage.setStyleName("extended-image"); layout.addComponent(extendedImage); Button moveButton = new Button("Move background", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Boolean val = extendedImage.getPosition(); if (val == null) { val = true; } extendedImage.setPosition(!val.booleanValue()); } }); layout.addComponent(moveButton); // Test how well scale image behaves inside alignment layout HorizontalLayout alignLayout = new HorizontalLayout(); alignLayout.setSpacing(true); alignLayout.setWidth("200px"); layout.addComponent(alignLayout); Label label = new Label("Alignment test:"); label.addStyleName("align-label"); alignLayout.addComponent(label); alignLayout.setExpandRatio(label, 1.0f); alignLayout.setComponentAlignment(label, Alignment.MIDDLE_CENTER); ScaleImage alignImage = new ScaleImage(); alignImage.setSource(new ThemeResource("images/tile-image.jpg")); alignImage.setWidth("20px"); alignImage.setHeight("20px"); alignLayout.addComponent(alignImage); alignLayout.setComponentAlignment(alignImage, Alignment.BOTTOM_CENTER); }
From source file:org.yozons.vaadin.ckeditor.CKEditorForVaadin7UI.java
License:Open Source License
@Override protected void init(VaadinRequest request) { getPage().setTitle("CKEditor for Vaadin 7"); final VerticalLayout layout = new VerticalLayout(); layout.setWidth(100, Unit.PERCENTAGE); layout.setMargin(true);//www . j av a2s . c om layout.setSpacing(true); setContent(layout); layout.addComponent(new Button("Hit server")); final String editor1InitialValue = "<p>CKEditor for Vaadin 7 is an entirely new JavaScriptComponent add-on.</p>"; CKEditorConfig config1 = new CKEditorConfig(); config1.useCompactTags(); config1.disableElementsPath(); config1.setResizeDir(CKEditorConfig.RESIZE_DIR.HORIZONTAL); config1.disableSpellChecker(); final CKEditor editor1 = new CKEditor(config1, editor1InitialValue); layout.addComponent(editor1); editor1.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(String newValue) { if (!newValue.equals(editor1.getValue())) Notification.show("ERROR - Event value does not match editor #1's current value"); else Notification.show("ValueChangeListener CKEditor v" + editor1.getVersion() + "/" + getVersion() + " - #1 contents: " + newValue); editor1.focus(); } }); Button testButton = new Button("Reset editor #1"); testButton.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { if (!editor1.isReadOnly()) { editor1.setValue(editor1InitialValue); Notification.show("Reset CKEditor v" + editor1.getVersion() + "/" + getVersion() + " - #1 contents: " + editor1.getValue()); } } }); layout.addComponent(testButton); Button toggleReadOnlyButton1 = new Button("Toggle read-only editor #1"); toggleReadOnlyButton1.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { editor1.setReadOnly(!editor1.isReadOnly()); } }); layout.addComponent(toggleReadOnlyButton1); Button toggleViewWithoutEditorButton1 = new Button("Toggle view-without-editor #1"); toggleViewWithoutEditorButton1.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { editor1.setViewWithoutEditor(!editor1.isViewWithoutEditor()); } }); layout.addComponent(toggleViewWithoutEditorButton1); // Now add in a second editor.... final String editor2InitialValue = "<p>Here is editor #2.</p><h1>Hope you find this useful in your Vaadin 7 projects.</h1>"; CKEditorConfig config2 = new CKEditorConfig(); config2.addCustomToolbarLine( "{ items : ['Source','Styles','Bold','VaadinSave','-','Undo','Redo','-','NumberedList','BulletedList'] }"); config2.enableVaadinSavePlugin(); config2.addToRemovePlugins("scayt"); final CKEditor editor2 = new CKEditor(config2); editor2.setWidth(600, Unit.PIXELS); layout.addComponent(editor2); editor2.setValue(editor2InitialValue); editor2.addValueChangeListener(new ValueChangeListener() { public void valueChange(String newValue) { if (!newValue.equals(editor2.getValue())) Notification.show("ERROR - Event value does not match editor #2's current value"); else Notification.show("ValueChangeListener CKEditor v" + editor2.getVersion() + "/" + getVersion() + " - #2 contents: " + newValue); } }); Button resetTextButton2 = new Button("Reset editor #2"); resetTextButton2.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { if (!editor2.isReadOnly()) { editor2.setValue(editor2InitialValue); Notification.show("Reset CKEditor v" + editor1.getVersion() + "/" + getVersion() + " - #2 contents: " + editor2.getValue()); } } }); layout.addComponent(resetTextButton2); Button toggleReadOnlyButton2 = new Button("Toggle read-only editor #2"); toggleReadOnlyButton2.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { editor2.setReadOnly(!editor2.isReadOnly()); } }); layout.addComponent(toggleReadOnlyButton2); Button toggleViewWithoutEditorButton2 = new Button("Toggle view-without-editor #2"); toggleViewWithoutEditorButton2.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { editor2.setViewWithoutEditor(!editor2.isViewWithoutEditor()); } }); layout.addComponent(toggleViewWithoutEditorButton2); // Now some extra tests for modal windows, etc. layout.addComponent(new Button("Open Modal Subwindow", new ClickListener() { @Override public void buttonClick(ClickEvent event) { Window sub = new Window("Subwindow modal"); VerticalLayout subLayout = new VerticalLayout(); sub.setContent(subLayout); CKEditorConfig config = new CKEditorConfig(); config.useCompactTags(); config.disableElementsPath(); config.disableSpellChecker(); config.enableVaadinSavePlugin(); // set BaseFloatZIndex 1000 higher than CKEditor's default of 10000; probably a result of an editor opening // in a window that's on top of the main two editors of this demo app config.setBaseFloatZIndex(11000); config.setHeight("150px"); final CKEditor ckEditor = new CKEditor(config); ckEditor.addValueChangeListener(new ValueChangeListener() { public void valueChange(String newValue) { Notification.show("CKEditor v" + ckEditor.getVersion() + "/" + getVersion() + " - POPUP MODAL contents: " + newValue); } }); ckEditor.focus(); subLayout.addComponent(ckEditor); sub.setWidth("80%"); sub.setModal(true); sub.center(); event.getButton().getUI().addWindow(sub); } })); layout.addComponent(new Button("Open Non-Modal Subwindow with 100% Height", new ClickListener() { @Override public void buttonClick(ClickEvent event) { Window sub = new Window("Subwindow non-modal 100% height"); VerticalLayout subLayout = new VerticalLayout(); sub.setContent(subLayout); sub.setWidth("80%"); sub.setHeight("500px"); subLayout.setSizeFull(); CKEditorConfig config = new CKEditorConfig(); config.useCompactTags(); config.disableElementsPath(); config.disableSpellChecker(); config.enableVaadinSavePlugin(); // set BaseFloatZIndex 1000 higher than CKEditor's default of 10000; probably a result of an editor opening // in a window that's on top of the main two editors of this demo app config.setBaseFloatZIndex(11000); config.setStartupFocus(true); final CKEditor ckEditor = new CKEditor(config); ckEditor.setHeight("100%"); ckEditor.addValueChangeListener(new ValueChangeListener() { public void valueChange(String newValue) { Notification.show("CKEditor v" + ckEditor.getVersion() + "/" + getVersion() + " - POPUP NON-MODAL 100% HEIGHT contents: " + ckEditor.getValue()); } }); subLayout.addComponent(ckEditor); subLayout.setExpandRatio(ckEditor, 1.0f); final TextField textField = new TextField("TextField"); textField.setImmediate(true); textField.addValueChangeListener(new Property.ValueChangeListener() { public void valueChange(ValueChangeEvent event) { Notification.show("TextField - POPUP NON-MODAL 100% HEIGHT contents: " + event.getProperty().getValue().toString()); } }); subLayout.addComponent(textField); sub.center(); event.getButton().getUI().addWindow(sub); } })); }
From source file:probe.com.view.body.quantdatasetsoverview.quantproteinstabsheet.peptidescontainer.popupcomponents.PeptideSequenceContainer.java
private void checkAndMerge() { TreeMap<Integer, StackedBarPeptideComponent> finalUpdatedPeptidesCoverageMap = new TreeMap<Integer, StackedBarPeptideComponent>(); TreeMap<Integer, StackedBarPeptideComponent> orderedCompoMap = new TreeMap<Integer, StackedBarPeptideComponent>(); for (StackedBarPeptideComponent peptideLayout : allPeptidesStackedBarComponentsMap) { if (orderedCompoMap.containsKey(peptideLayout.getX0())) { StackedBarPeptideComponent toReplaceComp = orderedCompoMap.remove(peptideLayout.getX0()); if (toReplaceComp.getWidthArea() <= peptideLayout.getWidthArea()) { orderedCompoMap.put(peptideLayout.getX0(), peptideLayout); } else { orderedCompoMap.put(toReplaceComp.getX0(), toReplaceComp); }// w w w. jav a2 s .co m } else { orderedCompoMap.put(peptideLayout.getX0(), peptideLayout); } } if (orderedCompoMap.size() == 1) { StackedBarPeptideComponent peptideI = orderedCompoMap.firstEntry().getValue(); finalUpdatedPeptidesCoverageMap.put(peptideI.getX0(), peptideI); } else { TreeMap<Integer, StackedBarPeptideComponent> refrenceOrderedCompoMap = new TreeMap<Integer, StackedBarPeptideComponent>( orderedCompoMap); while (true) { boolean merge = false; for (int keyI : orderedCompoMap.navigableKeySet()) { StackedBarPeptideComponent peptideI = orderedCompoMap.get(keyI); TreeMap<Integer, StackedBarPeptideComponent> comparableOrderedCompoMap = new TreeMap<Integer, StackedBarPeptideComponent>( refrenceOrderedCompoMap); comparableOrderedCompoMap.remove(keyI); for (int keyII : comparableOrderedCompoMap.navigableKeySet()) { StackedBarPeptideComponent peptideII = comparableOrderedCompoMap.get(keyII); if (((Integer) peptideII.getParam("start")) == ((Integer) peptideI.getParam("end") + 1) || (((Integer) peptideI.getParam("start")) == ((Integer) peptideII.getParam("end") + 1))) { // int x0 = Math.min(peptideI.getX0(), peptideII.getX0()); int widthArea = peptideI.getWidthArea() + peptideII.getWidthArea(); String sequence; if (peptideI.getX0() < peptideII.getX0()) { sequence = peptideI.getParam("sequence").toString() + peptideII.getParam("sequence"); } else { sequence = peptideII.getParam("sequence").toString() + peptideI.getParam("sequence"); } StackedBarPeptideComponent updatedCoverComp = new StackedBarPeptideComponent(x0, widthArea, "", ""); refrenceOrderedCompoMap.remove(keyI); refrenceOrderedCompoMap.remove(keyII); updatedCoverComp.setParam("sequence", sequence); updatedCoverComp.setParam("start", Math.min(((Integer) peptideI.getParam("start")), ((Integer) peptideII.getParam("start")))); updatedCoverComp.setParam("end", Math.max(((Integer) peptideI.getParam("end")), ((Integer) peptideII.getParam("end")))); refrenceOrderedCompoMap.put(x0 + 10000, updatedCoverComp); merge = true; break; } else if (((Integer) peptideII.getParam("start") > (Integer) peptideI.getParam("start")) && ((Integer) peptideII.getParam("end") > (Integer) peptideI.getParam("end")) && ((Integer) peptideII.getParam("start") < (Integer) peptideI.getParam("end"))) { //// int x0 = Math.min(peptideI.getX0(), peptideII.getX0()); int widthArea = 0; String sequence; if (peptideI.getX0() < peptideII.getX0()) { sequence = peptideI.getParam("sequence").toString() + peptideII.getParam("sequence"); widthArea = peptideII.getWidthArea() + (peptideII.getX0() - peptideI.getX0()); } else { sequence = peptideII.getParam("sequence").toString() + peptideI.getParam("sequence"); widthArea = peptideI.getWidthArea() + (peptideI.getX0() - peptideII.getX0()); } StackedBarPeptideComponent updatedCoverComp = new StackedBarPeptideComponent(x0, widthArea, "", ""); refrenceOrderedCompoMap.remove(keyI); refrenceOrderedCompoMap.remove(keyII); updatedCoverComp.setParam("sequence", sequence); updatedCoverComp.setParam("start", Math.min(((Integer) peptideI.getParam("start")), ((Integer) peptideII.getParam("start")))); updatedCoverComp.setParam("end", Math.max(((Integer) peptideI.getParam("end")), ((Integer) peptideII.getParam("end")))); refrenceOrderedCompoMap.put(x0 + 10000, updatedCoverComp); merge = true; break; } else if (((Integer) peptideII.getParam("start") > (Integer) peptideI.getParam("start")) && ((Integer) peptideII.getParam("end") <= (Integer) peptideI.getParam("end"))) { int x0 = Math.min(peptideI.getX0(), peptideII.getX0()); int widthArea = 0; String sequence; if (peptideI.getParam("sequence").toString() .contains(peptideII.getParam("sequence").toString())) { widthArea = peptideI.getWidthArea(); sequence = peptideI.getParam("sequence").toString(); } else { widthArea = peptideII.getWidthArea(); sequence = peptideII.getParam("sequence").toString(); } StackedBarPeptideComponent updatedCoverComp = new StackedBarPeptideComponent(x0, widthArea, "", ""); refrenceOrderedCompoMap.remove(keyI); refrenceOrderedCompoMap.remove(keyII); updatedCoverComp.setParam("sequence", sequence); updatedCoverComp.setParam("start", Math.min(((Integer) peptideI.getParam("start")), ((Integer) peptideII.getParam("start")))); updatedCoverComp.setParam("end", Math.max(((Integer) peptideI.getParam("end")), ((Integer) peptideII.getParam("end")))); refrenceOrderedCompoMap.put(x0 + 10000, updatedCoverComp); merge = true; break; } } } if (merge) { orderedCompoMap.clear(); orderedCompoMap.putAll(refrenceOrderedCompoMap); } else { break; } } finalUpdatedPeptidesCoverageMap.putAll(refrenceOrderedCompoMap); } // LinkedHashMap<Integer, Integer> startEndMap = new LinkedHashMap<Integer, Integer>(); // LinkedHashMap<Integer, StackedBarPeptideComponent> stackedPepSet = new LinkedHashMap<Integer, StackedBarPeptideComponent>(); // LinkedHashMap<Integer, StackedBarPeptideComponent> orderedCompoMap = new LinkedHashMap<Integer, StackedBarPeptideComponent>(); // for (StackedBarPeptideComponent peptideLayout : allPeptidesStackedBarComponentsMap) { // int start = (Integer) peptideLayout.getParam("start"); // int end = (Integer) peptideLayout.getParam("end"); // if (!startEndMap.containsKey(start)) { // int x0 = peptideLayout.getX0(); // int widthArea = peptideLayout.getWidthArea(); // String sequence = peptideLayout.getParam("sequence").toString(); // StackedBarPeptideComponent updatedCoverComp = new StackedBarPeptideComponent(x0, widthArea, "", ""); // updatedCoverComp.setParam("sequence", sequence); // updatedCoverComp.setParam("start", peptideLayout.getParam("start")); // updatedCoverComp.setParam("end", peptideLayout.getParam("end")); // startEndMap.put(start, end); // stackedPepSet.put(start, peptideLayout); // } else { // StackedBarPeptideComponent updatedCoverComp = stackedPepSet.remove(start); // int x0 = peptideLayout.getX0(); // int widthArea ; // String sequence; // if (updatedCoverComp.getParam("sequence").toString().contains(peptideLayout.getParam("sequence").toString())) { // widthArea = updatedCoverComp.getWidthArea(); // sequence = updatedCoverComp.getParam("sequence").toString(); // } else { // widthArea = peptideLayout.getWidthArea(); // sequence = peptideLayout.getParam("sequence").toString(); // } // // StackedBarPeptideComponent updatedCoverCompI = new StackedBarPeptideComponent(x0, widthArea, "", ""); // updatedCoverCompI.setParam("sequence", sequence); // updatedCoverCompI.setParam("start", peptideLayout.getParam("start")); // updatedCoverCompI.setParam("end", Math.max((Integer)peptideLayout.getParam("end"),(Integer)updatedCoverComp.getParam("end"))); // startEndMap.put(start,(Integer) updatedCoverCompI.getParam("end")); // stackedPepSet.put(start, updatedCoverCompI); // // } // // } for (StackedBarPeptideComponent peptideLayout : finalUpdatedPeptidesCoverageMap.values()) { VerticalLayout coverageComp = new VerticalLayout(); coverageComp.setStyleName("vdarkgray"); coverageComp.setHeight("15px"); coverageComp.setWidth(peptideLayout.getWidth(), peptideLayout.getWidthUnits()); coverageComp.setDescription("" + peptideLayout.getParam("start") + "-" + peptideLayout.getParam("sequence") + "-" + peptideLayout.getParam("end")); coveragePeptidesSequencesBar.addComponent(coverageComp, "left: " + (peptideLayout.getX0() - 20) + "px; top: " + (0) + "px;"); } }