/* (non-Javadoc) * @see org.eclipse.swt.widgets.Control#setEnabled(boolean) */ public void setEnabled(boolean enabled) { fTree.getControl().setEnabled(enabled); if (enabled) { updateButtons(); } else { fSelectButton.setEnabled(false); fSelectAllButton.setEnabled(false); fDeselectButton.setEnabled(false); fDeselectAllButton.setEnabled(false); fSelectRequiredButton.setEnabled(false); fCountLabel.setText(""); // $NON-NLS-1$ } fModeLabel.setEnabled(enabled); fPluginModeButton.setEnabled(enabled); fFeaureModeButton.setEnabled(enabled); fShowLabel.setEnabled(enabled); fShowPluginsButton.setEnabled(enabled); fShowSourceButton.setEnabled(enabled); boolean isPluginMode = !fFeaureModeButton.getSelection(); fGroupLabel.setEnabled(enabled && isPluginMode); if (fGroupCombo != null) { fGroupCombo.setEnabled(enabled && isPluginMode); } else { fGroupComboPart.setEnabled(enabled && isPluginMode); } }
public void jsr(Label label) throws IOException { // push(-1); int offset = size(); code.writeByte(168); label.setBranch(offset, 2); label.setStack(stack + 1); }
public static void main(String[] args) { Parser parser = new Parser(); Label labels = new Label(); String asmbly; int pc = 100; try { BufferedReader br = new BufferedReader(new FileReader(args[0])); String line; while ((line = br.readLine()) != null) { if (line.contains(":")) labels.fillLabels(line, pc); pc++; } } catch (Exception e) { System.out.println("Failed first"); } try { BufferedReader br = new BufferedReader(new FileReader(args[0])); PrintWriter writer = new PrintWriter("output", "UTF-8"); String line; while ((line = br.readLine()) != null) { asmbly = parser.parseLine(line, labels); writer.println(asmbly); } writer.close(); } catch (Exception e) { System.out.println("Failed second"); } }
void write(ClassEnv e, CodeAttr ce, DataOutputStream out) throws IOException, jasError { if (wide) { target.writeWideOffset(ce, source, out); } else { target.writeOffset(ce, source, out); } }
public void update_display(int lat, int lon, int alt, int heading) { String lat_str = Math.abs(lat) + "" + DEGREE + ((lat > 0) ? " N" : " S"); String long_str = Math.abs(lon) + "" + DEGREE + ((lon > 0) ? " E" : " W"); lat_.setText(lat_str); long_.setText(long_str); alt_.setText(alt + " Kft"); heading_.setText(heading + "" + DEGREE + " "); }
public void startRecording() { statusLabel.setText("Status: Recording..."); statusLabel.setFont(new Font("Helvetica", Font.BOLD, 12)); statusLabel.setForeground(Color.red); recordButton.setLabel("Stop recording"); recording = true; viewer.setRecordingStatus(fnameField.getText()); }
public void stopRecording() { statusLabel.setText("Status: Not recording."); statusLabel.setFont(new Font("Helvetica", Font.PLAIN, 12)); statusLabel.setForeground(Color.black); recordButton.setLabel("Record"); recording = false; viewer.setRecordingStatus(null); }
void write(ClassEnv e, CodeAttr ce, DataOutputStream out) throws IOException, jasError { if (wide) { target.writeWideOffset(ce, source, out); } else { int offset = ce.getPc(target); if (source != null) offset -= ce.getPc(source); if (offset > 32767 || offset < -32768) throw new jasError("reference from line " + ref + " exceed size for short"); target.writeOffset(ce, source, out); } }
public Position() { Panel grid_panel = new Panel(); lat_.setFont(FONT); long_.setFont(FONT); alt_.setFont(FONT); heading_.setFont(FONT); setLayout(new GridLayout(1, 4)); add(lat_); add(long_); add(heading_); add(alt_); }
/* WARNING: THIS METHOD WILL BE REGENERATED. */ private java.awt.Label getLabel1() { if (ivjLabel1 == null) { try { ivjLabel1 = new java.awt.Label(); ivjLabel1.setName("Label1"); ivjLabel1.setFont(new java.awt.Font("serif", 3, 24)); ivjLabel1.setAlignment(java.awt.Label.CENTER); ivjLabel1.setText("Name not found!"); ivjLabel1.setForeground(java.awt.Color.red); // user code begin {1} // user code end } catch (java.lang.Throwable ivjExc) { // user code begin {2} // user code end handleException(ivjExc); } } return ivjLabel1; }
public ReciveFile() { super("파일전송"); setLayout(null); lbl = new Label("파일 전송을 기다립니다."); lbl.setBounds(10, 30, 230, 20); lbl.setBackground(Color.gray); lbl.setForeground(Color.white); add(lbl); txt = new TextArea("", 0, 0, TextArea.SCROLLBARS_BOTH); txt.setBounds(10, 60, 230, 100); txt.setEditable(false); add(txt); btn = new Button("닫기"); btn.setBounds(105, 170, 40, 20); btn.setVisible(false); btn.addActionListener(this); add(btn); addWindowListener(new WinListener()); setSize(250, 200); show(); try { ServerSocket socket = new ServerSocket(port); Socket sock = null; FileThread client = null; try { sock = socket.accept(); client = new FileThread(this, sock); client.start(); } catch (IOException e) { System.out.println(e); try { if (sock != null) sock.close(); } catch (IOException e1) { System.out.println(e1); } finally { sock = null; } } } catch (IOException e) { } }
public void tableswitch(Label def, int low, Label[] labels) throws IOException { int position = size(); push(-1); code.writeByte(170); for (int j = 0; j < 3 - (position % 4); j++) code.writeByte(0); def.setBranch(position, 4); code.writeInt(low); code.writeInt(labels.length - 1); for (int i = 0; i < labels.length; i++) { labels[i].setBranch(position, 4); } }
@FXML private void initialize() throws IOException, ParseException { taskNLabel.setVisible(false); nextExecutionLabel.setVisible(false); actveLabel.setVisible(false); initData(); logger.info("Data were initialized"); taskName.setCellValueFactory(new PropertyValueFactory<Task, String>("title")); taskTable.setItems(userData2); taskTable .getSelectionModel() .selectedItemProperty() .addListener( new ChangeListener<Task>() { public void changed( ObservableValue<? extends Task> observable, Task oldValue, Task newValue) { showTaskDetails(newValue); } }); }
/** * Registers ChangeListeners and sets back references in <code>PanelModel</code> and its children. */ private void repair() { // traverse PanelModel and create all event links Iterator iter = panelIterator(); while (iter.hasNext()) { PanelHolder ph = (PanelHolder) iter.next(); ph.removeAllChangeListeners(); ph.addChangeListener(this); ph.setPanelModel(this); Iterator dgIter = ph.dataGroupIterator(); while (dgIter.hasNext()) { DataGroup dg = (DataGroup) dgIter.next(); dg.removeAllChangeListeners(); dg.addChangeListener(ph); dg.setPanelHolder(ph); dg.getXAxisHolder().removeAllChangeListeners(); dg.getXAxisHolder().addChangeListener(dg); dg.getXAxisHolder().setDataGroup(dg); dg.getYAxisHolder().removeAllChangeListeners(); dg.getYAxisHolder().addChangeListener(dg); dg.getYAxisHolder().setDataGroup(dg); } Iterator lbIter = ph.labelIterator(); while (lbIter.hasNext()) { Label lb = (Label) lbIter.next(); lb.removeAllChangeListeners(); lb.addChangeListener(ph); lb.setPanelHolder(ph); } Iterator lgIter = ph.legendIterator(); while (lgIter.hasNext()) { Legend lg = (Legend) lgIter.next(); lg.removeAllChangeListeners(); lg.addChangeListener(ph); lg.setPanelHolder(ph); } } }
void write(ClassEnv e, CodeAttr ce, DataOutputStream out) throws IOException, jasError { int pad; int source_pc = ce.getPc(source); if (((source_pc + 1) % 4) != 0) { // need padding pad = (4 - ((source_pc + 1) % 4)); for (int x = 0; x < pad; x++) out.writeByte(0); } dflt.writeWideOffset(ce, source, out); out.writeInt(min); out.writeInt(max); int cnt = jmp.length; for (int x = 0; x < cnt; x++) { jmp[x].writeWideOffset(ce, source, out); } }
/** * Creates the contents of this group, using the given toolkit where appropriate so that the * controls have the form editor look and feel. * * @param parent parent composite * @param toolkit toolkit to create controls with */ protected void createFormContents(Composite parent, FormToolkit toolkit) { fGrouping = GROUP_BY_NONE; Composite comp = toolkit.createComposite(parent); GridLayout layout = new GridLayout(2, false); layout.marginWidth = layout.marginHeight = 0; comp.setLayout(layout); comp.setLayoutData(new GridData(GridData.FILL_BOTH)); comp.setFont(parent.getFont()); createTree(comp, toolkit); createButtons(comp, toolkit); fCountLabel = toolkit.createLabel(comp, ""); // $NON-NLS-1$ GridData data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 2; fCountLabel.setLayoutData(data); updateButtons(); initializeFilters(); }
private void undoglobalfit() { for (int i = 0; i < ncurves; i++) { for (int j = 0; j < nparams; j++) { globalparams[i][j] = undoparams[i][j]; globalformulas[i][j] = undoformulas[i][j]; globalvflmatrix[i][j] = undovflmatrix[i][j]; } for (int j = 0; j < xpts; j++) { for (int k = 0; k < ypts; k++) { fit[i][j][k] = undofit[i][j][k]; } } if (i == dispcurve) { pwfit.updateSeries(fit[dispcurve], 1, true); } c2[i] = undoc2[i]; c2array[i].setText("" + (float) c2[i]); } globalc2 = undoglobalc2; globalc2label.setText("Global chi^2 = " + (float) globalc2); }
void write(ClassEnv e, CodeAttr ce, DataOutputStream out) throws IOException, jasError { int pad; int source_pc = ce.getPc(source); if (((source_pc + 1) % 4) != 0) { // need padding pad = (4 - ((source_pc + 1) % 4)); for (int x = 0; x < pad; x++) out.writeByte(0); } // write offset to default // as a 4 byte signed value dflt.writeWideOffset(ce, source, out); if (jmp == null) { out.writeInt(0); } else { out.writeInt(jmp.length); for (int x = 0; x < jmp.length; x++) { out.writeInt(match[x]); jmp[x].writeWideOffset(ce, source, out); } } }
/** * Set the container to display in the tree or <code>null</code> to disable the tree * * @param input bundle container or <code>null</code> */ public void setInput(ITargetDefinition input) { fTargetDefinition = input; // Update the cached data fFileBundleMapping = null; fAllBundles.clear(); if (input == null || !input.isResolved()) { fTree.setInput(Messages.TargetContentsGroup_10); setEnabled(false); return; } IResolvedBundle[] allResolvedBundles = input.getAllBundles(); if (allResolvedBundles == null || allResolvedBundles.length == 0) { fTree.setInput(Messages.TargetContentsGroup_11); setEnabled(false); return; } for (int i = 0; i < allResolvedBundles.length; i++) { fAllBundles.add(allResolvedBundles[i]); } boolean isFeatureMode = ((TargetDefinition) fTargetDefinition).getUIMode() == TargetDefinition.MODE_FEATURE; fFeaureModeButton.setSelection(isFeatureMode); fPluginModeButton.setSelection(!isFeatureMode); fGroupLabel.setEnabled(!isFeatureMode); fTree.getControl().setRedraw(false); fTree.setInput(fTargetDefinition); fTree.expandAll(); updateCheckState(); updateButtons(); setEnabled(true); fTree.getControl().setRedraw(true); }
// dessin et affichage d'un chemin depuis l'origine à partir de l'origine vers un sommet en // particulier public void print_chemin(Sommet dest) { if (maplabel.containsKey(dest)) { boolean var = true; Label lab = maplabel.get(dest); while (var) { // dessin du chemin. on n'affiche pas le chemin noeud par noeud car ca prend trop de place // dans la console if (lab.getCourant() == this.graphe.sommets.get(origine)) { break; } this.graphe.getDessin().setColor(Color.GREEN); this.graphe.getDessin().setWidth(3); this.graphe .getDessin() .drawLine( lab.getCourant().getlon(), lab.getCourant().getlat(), lab.getPere().getlon(), lab.getPere().getlat()); this.graphe.getDessin().setWidth(1); if (lab.getPere() == this.graphe.sommets.get(origine)) { break; } lab = maplabel.get(lab.getPere()); } // affichage du cout final if (this.getdist() && (this.getcovoit() == 0)) { System.out.println( maplabel.get(dest).getCout() / 1000.0 + " kilomètres et " + maplabel.get(dest).getCoutSec() + " min"); } else if (this.getcovoit() == 0) { System.out.println( maplabel.get(dest).getCout() + " min et " + maplabel.get(dest).getCoutSec() / 1000.0 + " kilomètres"); } } else { // le sommet destination n'est pas dans la hashmap->cout infini System.out.println("Cout infini"); } }
public void run() { if (!star) { System.out.println( "Run PCC de " + zoneOrigine + ":" + origine + " vers " + zoneDestination + ":" + destination); } if (star) { System.out.println( "Run PCC-Star de " + zoneOrigine + ":" + origine + " vers " + zoneDestination + ":" + destination); } // decision temps ou distance. Si on est en mode covoiturage, ce n'est pas nécessaire car on est // forcément en temps if (covoit == 0) { Scanner sc = new Scanner(System.in); System.out.println("En temps(0) ou distance(1)?"); if (sc.nextInt() == 1) { this.setdist(true); } } // chronometrage long start_time = System.currentTimeMillis(); Label l = new Label(false, 0.0, null, this.graphe.sommets.get(origine)); chem.add(l); tas.insert(l); maplabel.put(this.graphe.sommets.get(origine), l); // affichage de l'origine et de la destination this.graphe.getDessin().setColor(Color.BLUE); this.graphe .getDessin() .drawPoint( this.graphe.sommets.get(origine).getlon(), this.graphe.sommets.get(origine).getlat(), 10); this.graphe .getDessin() .drawPoint( this.graphe.sommets.get(destination).getlon(), this.graphe.sommets.get(destination).getlat(), 10); // compteur d'elements explores int nb_explor = 0; int tas_max = 0; while (!(tas.isEmpty())) { // extraction du minimum Label pere = tas.findMin(); tas.deleteMin(); // on arrete le programme une fois la destination trouvee, sauf si l'on ne souhaite pas // arreter ---> covoiturage if (pere.getCourant().getNum() == destination && (covoit == 0)) { System.out.println("Algorithme termine!"); break; } pere.setMarquage(true); chem.add(pere); for (Route route : pere.getCourant().routes) { Sommet suiv = route.getArrivee(); // affichage du parcours en temps reel. On ne le fait pas dans l'optimisation de covoiturage // car cela surcharge trop le dessin. if (this.getcovoit() == 0) { this.graphe.getDessin().setColor(Color.gray); this.graphe .getDessin() .drawLine( suiv.getlon(), suiv.getlat(), pere.getCourant().getlon(), pere.getCourant().getlat()); } // declarations des variables de cout, cout secondaire et estimation double new_cout = 0.0; double estim = 0.0; // ESTIMATION VERY IMPORTANT double cout_sec = 0.0; if (this.dist_temps) // Cout n distance { double vitesse = ((double) (route.getDesc().vitesseMax())); new_cout = pere.getCout() + ((double) (route.getDist())); // cout secondaire, ici en temps cout_sec = pere.getCoutSec() + (60.0 * ((double) (route.getDist())) / (1000.0 * vitesse)); if (this.star) { estim = suiv.dist_vol_oiseau(this.graphe.sommets.get(destination)); } } else { // Cout en temps double vitesse = ((double) (route.getDesc().vitesseMax())); // cas du pieton if (this.getcovoit() == 1 && (vitesse == 130.0 || vitesse == 110.0)) { // ici, le pieton ne peut pas acceder a cette route, // elle est reservee aux voitures, le cout est donc le plus grand possible new_cout = Double.MAX_VALUE; } else { if (this.getcovoit() == 1) { vitesse = 4.0; } new_cout = pere.getCout() + (60.0 * ((double) (route.getDist())) / (1000.0 * vitesse)); // cout secondaire, ici en distance cout_sec = pere.getCoutSec() + ((double) (route.getDist())); } // Ici on modifie le calcul de l'estimation dans le cas d'un calcul Astar. VERY IMPORTANT if (this.star) { estim = suiv.cout_vol_oiseau(this.graphe.sommets.get(destination), this.graphe.getvitmax()); } } // on regarde si le sommet a deja un label associe avec un cout different de l'infini) // pour ce faire, on verifie juste qu'il est integre a la hashmap ou pas if (maplabel.containsKey(suiv)) { maplabel.get(suiv).setEstim(estim); // maj du label, et de la hashmap // on ne verifie pas si le sommet est marque : en effet, s'il l'est, son cout // est deja minimal et la condition suivante sera toujours fausse. if (maplabel.get(suiv).getCout() > new_cout) { maplabel.get(suiv).setCout(new_cout); maplabel.get(suiv).setPere(pere.getCourant()); maplabel.get(suiv).setCoutSec(cout_sec); tas.update(maplabel.get(suiv)); } } else { // le sommet a un cout infini : on cree un label, et on l'integre a la hashmap Label lab = new Label(false, new_cout, pere.getCourant(), suiv); lab.setEstim(estim); lab.setCoutSec(cout_sec); tas.insert(lab); maplabel.put(suiv, lab); // compteurs de performance nb_explor++; if (tas.size() > tas_max) { tas_max = tas.size(); } } } } // on affiche le chemin this.print_chemin(this.graphe.sommets.get(destination)); // fin du chronometre long end_time = System.currentTimeMillis(); long difference = end_time - start_time; // on affiche les performances System.out.println("Temps écoulé en millisecondes : " + difference); System.out.println("Elements explorés : " + nb_explor); System.out.println("Taille max du tas : " + tas_max); }
private void fitglobal() { int nparams = 11; int nsel = 0; for (int i = 0; i < ncurves; i++) { if (include[i]) { nsel++; } } double[][] params = new double[nsel][nparams]; String[][] tempformulas = new String[nsel][nparams]; double[][][] constraints = new double[2][nsel][nparams]; int[][] vflmatrix = new int[nsel][nparams]; int counter = 0; for (int i = 0; i < ncurves; i++) { if (include[i]) { for (int j = 0; j < nparams; j++) { params[counter][j] = globalparams[i][j]; tempformulas[counter][j] = globalformulas[i][j]; constraints[0][counter][j] = globalconstraints[0][i][j]; constraints[1][counter][j] = globalconstraints[1][i][j]; vflmatrix[counter][j] = globalvflmatrix[i][j]; } counter++; } for (int j = 0; j < nparams; j++) { undoparams[i][j] = globalparams[i][j]; undoformulas[i][j] = globalformulas[i][j]; undovflmatrix[i][j] = globalvflmatrix[i][j]; } for (int j = 0; j < xpts; j++) { for (int k = 0; k < ypts; k++) { undofit[i][j][k] = fit[i][j][k]; } } undoc2[i] = c2[i]; } undoglobalc2 = globalc2; if (showglobalfitdialog(params, tempformulas, vflmatrix)) { counter = 0; for (int i = 0; i < ncurves; i++) { if (include[i]) { for (int j = 0; j < nparams; j++) { globalparams[i][j] = params[counter][j]; globalformulas[i][j] = tempformulas[counter][j]; globalvflmatrix[i][j] = vflmatrix[counter][j]; } counter++; } } double[] stats = new double[2]; float[][] tempdata = new float[nsel][xpts * ypts]; float[][] tempweights = new float[nsel][xpts * ypts]; counter = 0; for (int i = 0; i < ncurves; i++) { if (include[i]) { for (int j = 0; j < xpts; j++) { for (int k = 0; k < ypts; k++) { tempdata[counter][j + k * xpts] = (float) ((double) pch[i][j][k] / (double) nmeas[i]); tempweights[counter][j + k * xpts] = weights[i][j][k]; } } counter++; } } int tempmaxiter = globalfitclass.maxiter; if (checkc2) { globalfitclass.changemaxiter(0); } double[] tempc2vals = new double[nsel]; IJ.showStatus("Fitting Globally"); float[][] tempfit = globalfitclass.fitdata( params, vflmatrix, tempformulas, paramsnames, constraints, tempdata, tempweights, stats, tempc2vals, false); IJ.showStatus("Fit Complete"); globalfitclass.changemaxiter(tempmaxiter); globalc2 = stats[1]; globalc2label.setText("Global chi^2 = " + (float) globalc2); counter = 0; for (int i = 0; i < ncurves; i++) { if (include[i]) { for (int j = 0; j < xpts; j++) { for (int k = 0; k < ypts; k++) { fit[i][j][k] = tempfit[counter][j + xpts * k] * (float) nmeas[i]; } } if (i == dispcurve) { pwfit.updateSeries(fit[dispcurve], 1, true); } for (int j = 0; j < nparams; j++) { globalparams[i][j] = params[counter][j]; } c2[i] = tempc2vals[counter]; c2array[i].setText("" + (float) c2[i]); counter++; } } float[] temp = pwfit.getLimits(); temp[4] = 1.0f; pwfit.setLimits(temp); } }
void init(String[] names1, float[][][] pch1, int psfflag1) { setLayout(null); names = names1; pch = pch1; psfflag = psfflag1; ncurves = pch.length; nparams = 11; xpts = pch[0].length; ypts = pch[0][0].length; checkarray = new Checkbox[ncurves]; include = new boolean[ncurves]; namearray = new TextField[ncurves + 1]; int1array = new TextField[ncurves + 1]; intensity1 = new double[ncurves + 1]; e1array = new TextField[ncurves + 1]; n1array = new TextField[ncurves + 1]; bright1 = new double[ncurves + 1]; number1 = new double[ncurves + 1]; int2array = new TextField[ncurves + 1]; intensity2 = new double[ncurves + 1]; e2array = new TextField[ncurves + 1]; n2array = new TextField[ncurves + 1]; bright2 = new double[ncurves + 1]; number2 = new double[ncurves + 1]; eccarray = new TextField[ncurves + 1]; brightcc = new double[ncurves + 1]; eminccarray = new TextField[ncurves + 1]; brightmincc = new double[ncurves + 1]; c2array = new TextField[ncurves + 1]; c2 = new double[ncurves + 1]; nmeas = new int[ncurves + 1]; avg = new float[xpts][ypts]; indices = new int[ncurves]; beta = 0.05; getintbright(); for (int i = 0; i < ncurves; i++) { include[i] = true; indices[i] = i; } updateavg(); int starty = 60; int startx = 10; int yinc = 25; for (int i = 0; i <= ncurves; i++) { if (i != ncurves) { checkarray[i] = new Checkbox("", include[i]); checkarray[i].setBounds(startx, starty + i * yinc, 20, 20); checkarray[i].addItemListener(this); add(checkarray[i]); } namearray[i] = new TextField(names[i]); namearray[i].setBounds(startx + 30, starty + i * yinc, 200, 20); add(namearray[i]); int1array[i] = new TextField("" + (float) intensity1[i]); int1array[i].setBounds(startx + 30 + 210, starty + i * yinc, 40, 20); add(int1array[i]); e1array[i] = new TextField("" + (float) bright1[i]); e1array[i].setBounds(startx + 30 + 210 + 50, starty + i * yinc, 40, 20); add(e1array[i]); n1array[i] = new TextField("" + (float) number1[i]); n1array[i].setBounds(startx + 30 + 210 + 50 + 50, starty + i * yinc, 40, 20); add(n1array[i]); int2array[i] = new TextField("" + (float) intensity2[i]); int2array[i].setBounds(startx + 30 + 210 + 50 + 50 + 50, starty + i * yinc, 40, 20); add(int2array[i]); e2array[i] = new TextField("" + (float) bright2[i]); e2array[i].setBounds(startx + 30 + 210 + 50 + 50 + 50 + 50, starty + i * yinc, 40, 20); add(e2array[i]); n2array[i] = new TextField("" + (float) number2[i]); n2array[i].setBounds(startx + 30 + 210 + 50 + 50 + 50 + 50 + 50, starty + i * yinc, 40, 20); add(n2array[i]); eccarray[i] = new TextField("" + (float) brightcc[i]); eccarray[i].setBounds( startx + 30 + 210 + 50 + 50 + 50 + 50 + 50 + 50, starty + i * yinc, 40, 20); add(eccarray[i]); eminccarray[i] = new TextField("" + (float) brightmincc[i]); eminccarray[i].setBounds( startx + 30 + 210 + 50 + 50 + 50 + 50 + 50 + 50 + 50, starty + i * yinc, 40, 20); add(eminccarray[i]); c2[i] = 0.0; c2array[i] = new TextField("" + (float) c2[i]); c2array[i].setBounds( startx + 30 + 210 + 50 + 50 + 50 + 50 + 50 + 50 + 50 + 50, starty + i * yinc, 80, 20); add(c2array[i]); } namelabel = new Label("Filename"); namelabel.setBounds(startx + 30, starty - 25, 100, 20); add(namelabel); intlabel = new Label("<Ig>"); intlabel.setBounds(startx + 30 + 210, starty - 25, 40, 20); add(intlabel); brightlabel = new Label("<eg>"); brightlabel.setBounds(startx + 30 + 210 + 50, starty - 25, 40, 20); add(brightlabel); nlabel = new Label("<Ng>"); nlabel.setBounds(startx + 30 + 210 + 50 + 50, starty - 25, 40, 20); add(nlabel); int2label = new Label("<Ir>"); int2label.setBounds(startx + 30 + 210 + 50 + 50 + 50, starty - 25, 40, 20); add(int2label); bright2label = new Label("<er>"); bright2label.setBounds(startx + 30 + 210 + 50 + 50 + 50 + 50, starty - 25, 40, 20); add(bright2label); n2label = new Label("<Nr>"); n2label.setBounds(startx + 30 + 210 + 50 + 50 + 50 + 50 + 50, starty - 25, 40, 20); add(n2label); brightcclabel = new Label("<ecc>"); brightcclabel.setBounds(startx + 30 + 210 + 50 + 50 + 50 + 50 + 50 + 50, starty - 25, 40, 20); add(brightcclabel); brightccminlabel = new Label("min"); brightccminlabel.setBounds( startx + 30 + 210 + 50 + 50 + 50 + 50 + 50 + 50 + 50, starty - 25, 40, 20); add(brightccminlabel); c2label = new Label("chi^2"); c2label.setBounds( startx + 30 + 210 + 50 + 50 + 50 + 50 + 50 + 50 + 50 + 50, starty - 25, 80, 20); add(c2label); int buttonsx = startx + 30 + 210 + 50 + 50 + 50 + 50 + 50 + 50 + 50 + 50 + 90; fitavgbutton = new Button("Fit Avg"); fitavgbutton.setBounds(buttonsx, starty - 25, 100, 40); fitavgbutton.addActionListener(this); add(fitavgbutton); fitglobalbutton = new Button("Fit Global"); fitglobalbutton.setBounds(buttonsx, starty - 25 + 50, 100, 40); fitglobalbutton.addActionListener(this); add(fitglobalbutton); clearparamsbutton = new Button("Reset Fit Params"); clearparamsbutton.setBounds(buttonsx, starty - 25 + 50 + 50, 100, 40); clearparamsbutton.addActionListener(this); add(clearparamsbutton); checkc2 = false; fitclass = new NLLSfit(this, 0.0001, 50, 0.1); globalfitclass = new NLLSglobalfit(this, 0.0001, 50, 0.1); pchfunc = new pch2D((int) ((double) xpts * 1.5), (int) ((double) ypts * 1.5), psfflag); avgfit = new float[xpts][ypts]; fit = new float[ncurves][xpts][ypts]; xvals = new float[ncurves][xpts][ypts]; for (int i = 0; i < ncurves; i++) { for (int j = 0; j < xpts; j++) { for (int k = 0; k < ypts; k++) { xvals[i][j][k] = (float) k; fit[i][j][k] = 1.0f; } } } globalc2label = new Label("Global chi^2 = " + (float) 0.0); globalc2label.setBounds(buttonsx, starty - 25 + 50 + 50 + 50, 140, 20); add(globalc2label); dispcurvelabel = new Label("Display Fit #"); dispcurvelabel.setBounds(buttonsx, starty - 25 + 50 + 50 + 50 + 30, 70, 20); add(dispcurvelabel); dispcurvechoice = new Choice(); for (int i = 0; i < ncurves; i++) { dispcurvechoice.add("" + (i + 1)); } dispcurve = 0; dispcurvechoice.select(0); dispcurvechoice.setBounds(buttonsx + 80, starty - 25 + 50 + 50 + 50 + 30, 40, 20); dispcurvechoice.addItemListener(this); add(dispcurvechoice); betalabel = new Label("Bleedthrough f"); betalabel.setBounds(buttonsx, starty - 25 + 50 + 50 + 50 + 30 + 30, 100, 20); add(betalabel); betaval = new TextField("" + (float) beta); betaval.setBounds(buttonsx + 110, starty - 25 + 50 + 50 + 50 + 30 + 30, 40, 20); betaval.addActionListener(this); add(betaval); beta = Double.parseDouble(betaval.getText()); updatebeta(); undobutton = new Button("Undo Global Fit"); undobutton.setBounds(buttonsx, starty - 25 + 50 + 50 + 50 + 30 + 30 + 50, 100, 40); undobutton.addActionListener(this); add(undobutton); geterrorsbutton = new Button("Get Errors"); geterrorsbutton.setBounds(buttonsx, starty - 25 + 50 + 50 + 50 + 30 + 30 + 50 + 50, 100, 40); geterrorsbutton.addActionListener(this); add(geterrorsbutton); copylabel = new Label("copyright 2009 Jay Unruh ([email protected]) non-profit use only"); copylabel.setBounds(10, 790, 400, 20); add(copylabel); n_b_label = new Label("N and B Analysis"); n_b_label.setBounds(250, 10, 100, 20); add(n_b_label); pwavg = new PlotWindow3D("Avg", "kg", "kr", "Frequency", avg, 0); pwavg.setLogAxes(false, false, true); pwavg.draw(); pwavg.addPoints(avgfit, true, 0); float[] temp = pwavg.getLimits(); temp[4] = 1.0f; pwavg.setLimits(temp); float[][] temppch = new float[xpts][ypts]; for (int i = 0; i < xpts; i++) { System.arraycopy(pch[dispcurve][i], 0, temppch[i], 0, ypts); } pwfit = new PlotWindow3D("Selected Curve", "kg", "kr", "Frequency", temppch, 0); pwfit.setLogAxes(false, false, true); pwfit.draw(); pwfit.addPoints(fit[dispcurve], true, 0); float[] temp2 = pwfit.getLimits(); temp2[4] = 1.0f; pwfit.setLimits(temp2); resetparams(); repaint(); }
public void branch(int b, Label label) throws IOException { int offset = size(); code.writeByte(b); label.setBranch(offset, 2); label.setStack(stack); }
/** * Creates the buttons in this group inside a new composite * * @param parent parent composite * @param toolkit toolkit to give form style or <code>null</code> for dialog style */ private void createButtons(Composite parent, FormToolkit toolkit) { if (toolkit != null) { Composite buttonComp = toolkit.createComposite(parent); GridLayout layout = new GridLayout(); layout.marginWidth = layout.marginHeight = 0; buttonComp.setLayout(layout); buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL)); fSelectButton = toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_0, SWT.PUSH); fSelectButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fDeselectButton = toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_1, SWT.PUSH); fDeselectButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Label emptySpace = new Label(buttonComp, SWT.NONE); GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fSelectAllButton = toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_2, SWT.PUSH); fSelectAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fDeselectAllButton = toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_3, SWT.PUSH); fDeselectAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); emptySpace = new Label(buttonComp, SWT.NONE); gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fSelectRequiredButton = toolkit.createButton(buttonComp, Messages.TargetContentsGroup_4, SWT.PUSH); fSelectRequiredButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Composite filterComp = toolkit.createComposite(buttonComp); layout = new GridLayout(); layout.marginWidth = layout.marginHeight = 0; filterComp.setLayout(layout); filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true)); fModeLabel = toolkit.createLabel(filterComp, Messages.TargetContentsGroup_ManageUsing); fPluginModeButton = toolkit.createButton(filterComp, Messages.TargetContentsGroup_PluginMode, SWT.RADIO); fPluginModeButton.setSelection(true); fFeaureModeButton = toolkit.createButton(filterComp, Messages.TargetContentsGroup_FeatureMode, SWT.RADIO); fFeaureModeButton.setSelection(true); emptySpace = new Label(filterComp, SWT.NONE); gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fShowLabel = toolkit.createLabel(filterComp, Messages.BundleContainerTable_9); fShowPluginsButton = toolkit.createButton(filterComp, Messages.BundleContainerTable_14, SWT.CHECK); fShowPluginsButton.setSelection(true); fShowSourceButton = toolkit.createButton(filterComp, Messages.BundleContainerTable_15, SWT.CHECK); fShowSourceButton.setSelection(true); emptySpace = new Label(filterComp, SWT.NONE); gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fGroupLabel = toolkit.createLabel(filterComp, Messages.TargetContentsGroup_0); fGroupComboPart = new ComboPart(); fGroupComboPart.createControl(filterComp, toolkit, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalIndent = 10; fGroupComboPart.getControl().setLayoutData(gd); fGroupComboPart.setItems( new String[] { Messages.TargetContentsGroup_1, Messages.TargetContentsGroup_2, Messages.TargetContentsGroup_3 }); fGroupComboPart.setVisibleItemCount(30); fGroupComboPart.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { handleGroupChange(); } }); fGroupComboPart.select(0); } else { Composite buttonComp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_VERTICAL, 0, 0); fSelectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_0, null); fDeselectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_1, null); Label emptySpace = new Label(buttonComp, SWT.NONE); GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fSelectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_2, null); fDeselectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_3, null); emptySpace = new Label(buttonComp, SWT.NONE); gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fSelectRequiredButton = SWTFactory.createPushButton(buttonComp, Messages.TargetContentsGroup_4, null); Composite filterComp = SWTFactory.createComposite(buttonComp, 1, 1, SWT.NONE, 0, 0); filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true)); fModeLabel = SWTFactory.createLabel(filterComp, Messages.TargetContentsGroup_ManageUsing, 1); fPluginModeButton = SWTFactory.createRadioButton(filterComp, Messages.TargetContentsGroup_PluginMode); fFeaureModeButton = SWTFactory.createRadioButton(filterComp, Messages.TargetContentsGroup_FeatureMode); emptySpace = new Label(filterComp, SWT.NONE); gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fShowLabel = SWTFactory.createLabel(filterComp, Messages.BundleContainerTable_9, 1); fShowPluginsButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_14, null, true, 1); fShowSourceButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_15, null, true, 1); emptySpace = new Label(filterComp, SWT.NONE); gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fGroupLabel = SWTFactory.createLabel(filterComp, Messages.TargetContentsGroup_0, 1); fGroupCombo = SWTFactory.createCombo( filterComp, SWT.READ_ONLY, 1, new String[] { Messages.TargetContentsGroup_1, Messages.TargetContentsGroup_2, Messages.TargetContentsGroup_3 }); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalIndent = 10; fGroupCombo.setLayoutData(gd); fGroupCombo.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { handleGroupChange(); } }); fGroupCombo.select(0); } fSelectButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (!fTree.getSelection().isEmpty()) { Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray(); for (int i = 0; i < selected.length; i++) { fTree.setChecked(selected[i], true); } saveIncludedBundleState(); contentChanged(); updateButtons(); fTree.update( fTargetDefinition.getBundleContainers(), new String[] {IBasicPropertyConstants.P_TEXT}); } } }); fDeselectButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (!fTree.getSelection().isEmpty()) { Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray(); for (int i = 0; i < selected.length; i++) { fTree.setChecked(selected[i], false); } saveIncludedBundleState(); contentChanged(); updateButtons(); fTree.update( fTargetDefinition.getBundleContainers(), new String[] {IBasicPropertyConstants.P_TEXT}); } } }); fSelectAllButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { fTree.setAllChecked(true); saveIncludedBundleState(); contentChanged(); updateButtons(); fTree.update( fTargetDefinition.getBundleContainers(), new String[] {IBasicPropertyConstants.P_TEXT}); } }); fDeselectAllButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { fTree.setAllChecked(false); saveIncludedBundleState(); contentChanged(); updateButtons(); fTree.update( fTargetDefinition.getBundleContainers(), new String[] {IBasicPropertyConstants.P_TEXT}); } }); fSelectRequiredButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Object[] allChecked = fTree.getCheckedLeafElements(); Object[] required = null; if (fFeaureModeButton.getSelection()) { required = getRequiredFeatures(fTargetDefinition.getAllFeatures(), allChecked); } else { required = getRequiredPlugins(fAllBundles, allChecked); } for (int i = 0; i < required.length; i++) { fTree.setChecked(required[i], true); } saveIncludedBundleState(); contentChanged(); updateButtons(); fTree.update( fTargetDefinition.getBundleContainers(), new String[] {IBasicPropertyConstants.P_TEXT}); } }); fPluginModeButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { // Moving from feature based filtering to plug-in based, need to update storage ((TargetDefinition) fTargetDefinition).setUIMode(TargetDefinition.MODE_PLUGIN); contentChanged(); fTargetDefinition.setIncluded(null); fGroupLabel.setEnabled(true); if (fGroupCombo != null) { fGroupCombo.setEnabled(true); } else { fGroupComboPart.getControl().setEnabled(true); } fTree.getControl().setRedraw(false); fTree.refresh(false); fTree.expandAll(); updateCheckState(); updateButtons(); fTree.getControl().setRedraw(true); } }); fPluginModeButton.setSelection(true); GridData gd = new GridData(); gd.horizontalIndent = 10; fPluginModeButton.setLayoutData(gd); fFeaureModeButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { // Moving from plug-in based filtering to feature based, need to update storage ((TargetDefinition) fTargetDefinition).setUIMode(TargetDefinition.MODE_FEATURE); contentChanged(); fTargetDefinition.setIncluded(null); fGroupLabel.setEnabled(false); if (fGroupCombo != null) { fGroupCombo.setEnabled(false); } else { fGroupComboPart.getControl().setEnabled(false); } fTree.getControl().setRedraw(false); fTree.refresh(false); fTree.expandAll(); updateCheckState(); updateButtons(); fTree.getControl().setRedraw(true); } }); fFeaureModeButton.setSelection(false); gd = new GridData(); gd.horizontalIndent = 10; fFeaureModeButton.setLayoutData(gd); fShowPluginsButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (!fShowPluginsButton.getSelection()) { fTree.addFilter(fPluginFilter); } else { fTree.removeFilter(fPluginFilter); fTree.expandAll(); updateCheckState(); } updateButtons(); } }); fShowPluginsButton.setSelection(true); gd = new GridData(); gd.horizontalIndent = 10; fShowPluginsButton.setLayoutData(gd); fShowSourceButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (!fShowSourceButton.getSelection()) { fTree.addFilter(fSourceFilter); } else { fTree.removeFilter(fSourceFilter); fTree.expandAll(); updateCheckState(); } updateButtons(); } }); fShowSourceButton.setSelection(true); gd = new GridData(); gd.horizontalIndent = 10; fShowSourceButton.setLayoutData(gd); }
private void updateButtons() { if (fTargetDefinition != null && !fTree.getSelection().isEmpty()) { Object[] selection = ((IStructuredSelection) fTree.getSelection()).toArray(); boolean hasResolveBundle = false; boolean hasParent = false; boolean allSelected = true; boolean noneSelected = true; for (int i = 0; i < selection.length; i++) { if (!hasResolveBundle || !hasParent) { if (selection[i] instanceof IResolvedBundle) { hasResolveBundle = true; } else { hasParent = true; } } boolean checked = fTree.getChecked(selection[i]); if (checked) { noneSelected = false; } else { allSelected = false; } } // Selection is available if not everything is already selected and not both a parent and // child item are selected fSelectButton.setEnabled(!allSelected && !(hasResolveBundle && hasParent)); fDeselectButton.setEnabled(!noneSelected && !(hasResolveBundle && hasParent)); } else { fSelectButton.setEnabled(false); fDeselectButton.setEnabled(false); } int total = fAllBundles.size(); if (fFeaureModeButton.getSelection()) { if (fTargetDefinition == null) { total = 0; } else { total = fTargetDefinition.getAllFeatures().length; total += ((TargetDefinition) fTargetDefinition).getOtherBundles().length; } } if (fMissing != null) { total += fMissing.size(); } fSelectAllButton.setEnabled(fTargetDefinition != null && fTree.getCheckedLeafCount() != total); fDeselectAllButton.setEnabled(fTargetDefinition != null && fTree.getCheckedLeafCount() != 0); fSelectRequiredButton.setEnabled( fTargetDefinition != null && fTree.getCheckedLeafCount() > 0 && fTree.getCheckedLeafCount() != total); if (fTargetDefinition != null) { fCountLabel.setText( MessageFormat.format( Messages.TargetContentsGroup_9, new String[] { Integer.toString(fTree.getCheckedLeafCount()), Integer.toString(total) })); } else { fCountLabel.setText(""); // $NON-NLS-1$ } }
public void actionPerformed(ActionEvent ae) { org.omg.CORBA.StringHolder str = new org.omg.CORBA.StringHolder(); annuaire.chercheNom(texte.getText(), str); intitule.setText(str.value); }
void showStatus(String s) { statusLine.setText(s); }
/** * If 'applet' is not null, creates a new ImageJ frame that runs as an applet. If 'mode' is * ImageJ.EMBEDDED and 'applet is null, creates an embedded (non-standalone) version of ImageJ. */ public ImageJ(java.applet.Applet applet, int mode) { super("ImageJ"); embedded = applet == null && (mode == EMBEDDED || mode == NO_SHOW); this.applet = applet; String err1 = Prefs.load(this, applet); if (IJ.isLinux()) { backgroundColor = new Color(240, 240, 240); setBackground(backgroundColor); } Menus m = new Menus(this, applet); String err2 = m.addMenuBar(); m.installPopupMenu(this); setLayout(new GridLayout(2, 1)); // Tool bar toolbar = new Toolbar(); toolbar.addKeyListener(this); add(toolbar); // Status bar statusBar = new Panel(); statusBar.setLayout(new BorderLayout()); statusBar.setForeground(Color.black); statusBar.setBackground(backgroundColor); statusLine = new Label(); statusLine.setFont(SansSerif12); statusLine.addKeyListener(this); statusLine.addMouseListener(this); statusBar.add("Center", statusLine); progressBar = new ProgressBar(120, 20); progressBar.addKeyListener(this); progressBar.addMouseListener(this); statusBar.add("East", progressBar); statusBar.setSize(toolbar.getPreferredSize()); add(statusBar); IJ.init(this, applet); addKeyListener(this); addWindowListener(this); setFocusTraversalKeysEnabled(false); Point loc = getPreferredLocation(); Dimension tbSize = toolbar.getPreferredSize(); int ijWidth = tbSize.width + 10; int ijHeight = 100; setCursor(Cursor.getDefaultCursor()); // work-around for JDK 1.1.8 bug if (mode != NO_SHOW) { if (IJ.isWindows()) try { setIcon(); } catch (Exception e) { } setBounds(loc.x, loc.y, ijWidth, ijHeight); // needed for pack to work setLocation(loc.x, loc.y); pack(); setResizable(!(IJ.isMacintosh() || IJ.isWindows())); // make resizable on Linux show(); } if (err1 != null) IJ.error(err1); if (err2 != null) { IJ.error(err2); IJ.runPlugIn("ij.plugin.ClassChecker", ""); } m.installStartupMacroSet(); if (IJ.isMacintosh() && applet == null) { Object qh = null; qh = IJ.runPlugIn("MacAdapter", ""); if (qh == null) IJ.runPlugIn("QuitHandler", ""); } if (applet == null) IJ.runPlugIn("ij.plugin.DragAndDrop", ""); String str = m.getMacroCount() == 1 ? " macro" : " macros"; IJ.showStatus(version() + m.getPluginCount() + " commands; " + m.getMacroCount() + str); // if (applet==null && !embedded && Prefs.runSocketListener) // new SocketListener(); configureProxy(); if (applet == null) loadCursors(); }
/** @param el */ public BookImage(Books el, String user) { super(); this.Book = el; this.setStyleName("cells"); this.setHeight("250px"); this.setWidth("200px"); rating.setAnimated(true); rating.setCaption(null); rating.setMaxValue(5); rating.setStyleName("rating"); rating.setReadOnly(true); rating_my.setAnimated(true); rating_my.setCaption(null); rating_my.setMaxValue(5); rating_my.setStyleName("rating_my"); IRaitingService iRaitingService = new IRaitingService(); try { double rate = iRaitingService.getRaiting(el.getId()); rating.setReadOnly(false); rating.setValue(rate); rating.setReadOnly(true); double myrate = iRaitingService.getRaiting(user, el.getId()); rating_my.setValue(myrate); } catch (SQLException e) { e.printStackTrace(); } rating_my.addValueChangeListener( e -> { try { Rating rat = iRaitingService.getUser( getUI().getSession().getAttribute("user").toString(), el.getId()); rat.setRaiting(rating_my.getValue()); iRaitingService.update(rat); double rate = iRaitingService.getRaiting(el.getId()); rating.setReadOnly(false); rating.setValue(rate); rating.setReadOnly(true); new Notification(String.valueOf(rate), Notification.Type.TRAY_NOTIFICATION) .show(Page.getCurrent()); } catch (SQLException e1) { e1.printStackTrace(); } }); rating_layout.addComponent(rating); rating_layout.addComponent(rating_my); rating_layout.setComponentAlignment(rating, Alignment.MIDDLE_LEFT); rating_layout.setComponentAlignment(rating_my, Alignment.MIDDLE_LEFT); rating_layout.setStyleName("ratinglayout"); imageEmbedded.setSource(new FileResource(new File(Book.getImage()))); title.setValue(Book.getTitle()); author.setValue(Book.getAuthor()); if (Book.getFile().isEmpty()) buttonDownload.setEnabled(false); buttonDownload.setWidth("80%"); imageEmbedded.setWidth("100%"); imageEmbedded.setHeight("100%"); title.setWidth(null); author.setWidth(null); VerticalLayout bodyLayout = new VerticalLayout(title, author, imageEmbedded); bodyLayout.setExpandRatio(title, 12); bodyLayout.setExpandRatio(author, 8); bodyLayout.setExpandRatio(imageEmbedded, 80); bodyLayout.setSizeFull(); bodyLayout.setComponentAlignment(title, Alignment.MIDDLE_CENTER); bodyLayout.setComponentAlignment(author, Alignment.MIDDLE_CENTER); bodyLayout.setComponentAlignment(imageEmbedded, Alignment.MIDDLE_CENTER); buttonDownload.setStyleName("super-button"); title.setStyleName("name-label"); author.setStyleName("author-label"); this.addComponent(rating_layout); this.addComponent(bodyLayout); this.addComponent(buttonDownload); this.setComponentAlignment(rating_layout, Alignment.TOP_CENTER); this.setComponentAlignment(bodyLayout, Alignment.TOP_CENTER); this.setComponentAlignment(buttonDownload, Alignment.BOTTOM_CENTER); this.setExpandRatio(rating_layout, 5); this.setExpandRatio(bodyLayout, 85); this.setExpandRatio(buttonDownload, 10); StreamResource sr = getStream(); FileDownloader fileDownloader = new FileDownloader(sr); fileDownloader.extend(buttonDownload); bodyLayout.addLayoutClickListener( e -> { BookWin win = new BookWin(this.Book); UI.getCurrent().addWindow(win); }); }