List of usage examples for com.itextpdf.text.pdf.codec Base64 encodeBytes
public static String encodeBytes(byte[] source)
From source file:dbedit.Config.java
License:Open Source License
protected static String encrypt(String decrypted) throws GeneralSecurityException { if (decrypted == null || "".equals(decrypted)) { return decrypted; }// w w w. j av a 2s. c om Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, KEY); return Base64.encodeBytes(cipher.doFinal(decrypted.getBytes())); }
From source file:probe.com.model.util.vaadintoimageutil.Convertor.java
public String toImage(int height, int width, JComponent component) { BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = image.createGraphics(); graphics.setPaint(Color.WHITE); component.paint(graphics);//from w w w. ja v a2s . c o m // super.paint(graphics); byte[] imageData = null; try { imageData = in.encode(image); } catch (Exception e) { System.out.println(e.getLocalizedMessage()); } String base64 = Base64.encodeBytes(imageData); base64 = "data:image/png;base64," + base64; return base64; }
From source file:probe.com.model.util.vaadintoimageutil.HeatmapSwingComponent.java
public String generateHeatmap(String[] rows, String[] columns, String[][] data) { JPanel heatmapPanelLayout = new JPanel(); heatmapPanelLayout.setLayout(null);//from w w w . j a v a 2 s .com heatmapPanelLayout.setVisible(true); heatmapPanelLayout.setBorder(new LineBorder(Color.BLACK)); int width = (columns.length + 1) * 50; int height = (rows.length + 1) * 50; heatmapPanelLayout.setSize(width, height); JPanel cornerCell = initCell("#ffffff", 0, 0); int x = 50; int y = 0; heatmapPanelLayout.add(cornerCell); for (String headerCell : columns) { JPanel cell = initCell(headerCell, x, y); x += 50; heatmapPanelLayout.add(cell); } y = 50; for (String headerCell : rows) { JPanel cell = initCell(headerCell, 0, y); y += 50; heatmapPanelLayout.add(cell); } x = 50; y = 50; for (String[] row : data) { for (String color : row) { JPanel cell = initCell(color, x, y); heatmapPanelLayout.add(cell); x += 50; } x = 50; y += 50; } BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = image.createGraphics(); graphics.setPaint(Color.WHITE); heatmapPanelLayout.paint(graphics); // super.paint(graphics); byte[] imageData = null; try { ImageEncoder in = ImageEncoderFactory.newInstance(ImageFormat.PNG, new Float(0.084666f)); imageData = in.encode(image); } catch (Exception e) { System.out.println(e.getLocalizedMessage()); } String base64 = Base64.encodeBytes(imageData); base64 = "data:image/png;base64," + base64; return base64; // // JFrame frame = new JFrame(); // frame.setSize(1000, 1000); // frame.add(heatmapPanelLayout); // frame.setVisible(true); // return ""; }
From source file:probe.com.view.body.quantdatasetsoverview.diseasegroupsfilters.heatmap.HeatMapImgGenerator.java
public String generateHeatmap(String[] rows, String[] columns, String[][] data) { JPanel heatmapPanelLayout = new JPanel(); heatmapPanelLayout.setLayout(null);// w w w. ja va2s .com heatmapPanelLayout.setVisible(true); int width = (columns.length + 1) * 50; int height = (rows.length + 1) * 50; heatmapPanelLayout.setSize(width, height); JPanel cornerCell = initCell("#ffffff", 0, 0); int x = 50; int y = 0; heatmapPanelLayout.add(cornerCell); for (String headerCell : columns) { JPanel cell = initCell(headerCell, x, y); x += 50; heatmapPanelLayout.add(cell); } y = 50; for (String headerCell : rows) { JPanel cell = initCell(headerCell, 0, y); y += 50; heatmapPanelLayout.add(cell); } x = 50; y = 50; for (String[] row : data) { for (String color : row) { JPanel cell = initCell(color, x, y); heatmapPanelLayout.add(cell); x += 50; } x = 50; y += 50; } BufferedImage image = new BufferedImage(width + 10, height + 10, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = image.createGraphics(); graphics.setPaint(Color.WHITE); graphics.setBackground(Color.WHITE); heatmapPanelLayout.paint(graphics); byte[] imageData = null; try { ImageEncoder in = ImageEncoderFactory.newInstance(ImageFormat.PNG, new Float(0.084666f)); imageData = in.encode(image); } catch (Exception e) { System.out.println(e.getLocalizedMessage()); } String base64 = Base64.encodeBytes(imageData); base64 = "data:image/png;base64," + base64; return base64; }