Search in sources :

Example 16 with java.awt.image

use of java.awt.image in project ChatGameFontificator by GlitchCog.

the class SpriteFont method getEmojiDimensions.

/**
     * Get the dimensions of an emoji image
     * 
     * @param img
     * @param emojiConfig
     * @return
     */
private int[] getEmojiDimensions(LazyLoadEmoji emoji, ConfigEmoji emojiConfig) {
    Image img = emoji.getImage(emojiConfig.isAnimationEnabled());
    int iw;
    int ih;
    if (img == null) {
        switch(emojiConfig.getDisplayStrategy()) {
            case SPACE:
            case BOX_FILL:
            case BOX_FRAME:
                iw = emoji.getWidth();
                ih = emoji.getHeight();
                break;
            case UNKNOWN:
                // non-extended range
                return new int[] { getCharacterWidth(null, new SpriteCharacterKey(config.getUnknownChar()), emojiConfig), 1 };
            case NOTHING:
            default:
                iw = 0;
                ih = 1;
                break;
        }
    } else {
        iw = emoji.getWidth();
        ih = emoji.getHeight();
    }
    float h;
    float w;
    float eScale = emoji.getType().isBadge() ? (emojiConfig.getBadgeScale() / 100.0f) : (emojiConfig.getEmojiScale() / 100.0f);
    if ((emoji.getType().isBadge() && emojiConfig.isBadgeScaleToLine()) || (!emoji.getType().isBadge() && emojiConfig.isEmojiScaleToLine())) {
        final float emojiScaleRatio = eScale * getLineHeightScaled() / (float) ih;
        h = ih * emojiScaleRatio;
        w = iw * h / ih;
    } else {
        w = eScale * iw;
        h = eScale * ih;
    }
    return new int[] { (int) w, (int) h };
}
Also used : Image(java.awt.Image)

Example 17 with java.awt.image

use of java.awt.image in project adempiere by adempiere.

the class HelpAbout method createAndShowGui.

// METHODS
// =======
/**
	 * Create the GUI and show it
	 * @param component the calling component
	 */
@SuppressWarnings("unchecked")
public void createAndShowGui(Component component) {
    // title
    setTitle(s_logger.localizeMessage("guiAboutTitle"));
    // load icons
    ArrayList<Image> images = new ArrayList<Image>();
    images.add(getImage("AD16.png"));
    images.add(getImage("AD32.png"));
    setIconImages(images);
    // content pane
    Container pane = getContentPane();
    Locale locale = Locale.getDefault();
    pane.setComponentOrientation(ComponentOrientation.getOrientation(locale));
    pane.setLayout(new GridBagLayout());
    m_rowCounter = 0;
    // logo
    JLabel logo = new JLabel(new ImageIcon(getImage("ADempiere.png")));
    // heading
    JLabel label = new JLabel(s_logger.localizeMessage("guiAboutHeading"));
    label.setFont(new Font("Dialog", Font.BOLD, 14));
    pane.add(label, getHeadingConstraints());
    // display additional information if we are running in an Adempiere environment
    try {
        Class ademp = Class.forName("org.compiere.Adempiere", false, this.getClass().getClassLoader());
        // Adempiere Logo image & subtitle
        logo.setIcon(new ImageIcon(getImage("AD10030.png")));
        Field subtitle = ademp.getField("SUB_TITLE");
        logo.setText(subtitle.get(null).toString());
        logo.setHorizontalTextPosition(SwingConstants.CENTER);
        logo.setVerticalTextPosition(SwingConstants.BOTTOM);
        logo.setFont(new Font("Serif", Font.ITALIC, 10));
        logo.setForeground(Color.BLUE);
        // Adempiere version
        Field mainVersion = ademp.getField("MAIN_VERSION");
        Field dateVersion = ademp.getField("DATE_VERSION");
        String versionString = new StringBuffer(mainVersion.get(null).toString()).append(" @ ").append(dateVersion.get(null).toString()).toString();
        label = new JLabel(versionString);
        pane.add(label, getVersionConstraints());
        // Adempiere Copyright
        Field copyright = ademp.getField("COPYRIGHT");
        label = new JLabel(copyright.get(null).toString());
        pane.add(label, getAdempCprConstraints());
        // Adempiere URL
        Field url = ademp.getField("URL");
        label = new JLabel(url.get(null).toString());
        label.setForeground(Color.BLUE);
        pane.add(label, getUrlConstraints());
    } catch (Exception e) {
    // do nothing if any error occurs trying to access Adempiere class
    }
    // add logo to pane
    // (constraints depend on how many rows were added by above Adempiere information)
    pane.add(logo, getLogoConstraints());
    // program title
    label = new JLabel(s_logger.localizeMessage("guiWindowTitle"));
    label.setFont(new Font("DIALOG", Font.BOLD, 18));
    label.setForeground(Color.RED);
    pane.add(label, getTitleConstraints());
    // program description
    label = new JLabel(s_logger.localizeMessage("guiWindowDescription"));
    label.setFont(new Font("Dialog", Font.ITALIC, 12));
    pane.add(label, getDescrConstraints());
    //copyright
    JTextArea text = new JTextArea(s_logger.localizeMessage("copyright"));
    text.setFont(new Font("Dialog", Font.PLAIN, 10));
    text.setBackground(label.getBackground());
    pane.add(text, getCopyrConstraints());
    // close button
    m_buttonClose = new JButton(s_logger.localizeMessage("guiButtonClose"));
    m_buttonClose.setMnemonic(new Integer(s_logger.localizeMessage("guiButtonCloseMnemonic")));
    m_buttonClose.setIcon(new ImageIcon(getImage("Cancel16.png")));
    m_buttonClose.addActionListener(this);
    pane.add(m_buttonClose, getCloseConstraints());
    // show dialog
    pack();
    validate();
    m_buttonClose.requestFocusInWindow();
    setLocationRelativeTo(component);
    setVisible(true);
}
Also used : Locale(java.util.Locale) ImageIcon(javax.swing.ImageIcon) JTextArea(javax.swing.JTextArea) GridBagLayout(java.awt.GridBagLayout) ArrayList(java.util.ArrayList) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Image(java.awt.Image) Font(java.awt.Font) Field(java.lang.reflect.Field) Container(java.awt.Container)

Example 18 with java.awt.image

use of java.awt.image in project adempiere by adempiere.

the class HelpInfo method createAndShowGui.

// METHODS
// =======
/**
	 * Create the GUI and show it
	 * @param component the calling component
	 */
public void createAndShowGui(Component component) {
    // title
    setTitle(s_logger.localizeMessage("guiHelpTitle"));
    // load icons
    ArrayList<Image> images = new ArrayList<Image>();
    images.add(getImage("AD16.png"));
    images.add(getImage("AD32.png"));
    setIconImages(images);
    // content pane
    Container pane = getContentPane();
    Locale locale = Locale.getDefault();
    pane.setComponentOrientation(ComponentOrientation.getOrientation(locale));
    pane.setLayout(new GridBagLayout());
    // help text
    JEditorPane info = new JEditorPane();
    info.setEditable(false);
    info.setContentType("text/html");
    HTMLDocument htmlDoc = (HTMLDocument) info.getEditorKit().createDefaultDocument();
    info.setDocument(htmlDoc);
    info.setText(getHelpText());
    info.setCaretPosition(0);
    // scrollable pane for help text
    JScrollPane infoPane = new JScrollPane();
    infoPane.setBorder(BorderFactory.createLoweredBevelBorder());
    infoPane.setPreferredSize(new Dimension(500, 400));
    infoPane.getViewport().add(info, null);
    pane.add(infoPane, getInfoPaneConstraints());
    // close button
    m_buttonClose = new JButton(s_logger.localizeMessage("guiButtonClose"));
    m_buttonClose.setMnemonic(new Integer(s_logger.localizeMessage("guiButtonCloseMnemonic")));
    m_buttonClose.setIcon(new ImageIcon(getImage("Cancel16.png")));
    m_buttonClose.addActionListener(this);
    pane.add(m_buttonClose, getCloseConstraints());
    // show dialog
    pack();
    validate();
    m_buttonClose.requestFocusInWindow();
    setLocationRelativeTo(component);
    setVisible(true);
}
Also used : Locale(java.util.Locale) JScrollPane(javax.swing.JScrollPane) ImageIcon(javax.swing.ImageIcon) GridBagLayout(java.awt.GridBagLayout) HTMLDocument(javax.swing.text.html.HTMLDocument) ArrayList(java.util.ArrayList) JButton(javax.swing.JButton) Dimension(java.awt.Dimension) Image(java.awt.Image) Container(java.awt.Container) JEditorPane(javax.swing.JEditorPane)

Example 19 with java.awt.image

use of java.awt.image in project adempiere by adempiere.

the class LayoutEngine method layout.

//	getPaper
/**************************************************************************
	 * 	Create Layout
	 */
private void layout() {
    //	Header/Footer
    m_headerFooter = new HeaderFooter(m_printCtx);
    if (!m_format.isForm() && m_format.isStandardHeaderFooter())
        createStandardHeaderFooter();
    //
    m_pageNo = 0;
    m_pages.clear();
    m_tableElement = null;
    //	initialize
    newPage(true, false);
    //
    if (m_format.isForm())
        layoutForm();
    else {
        //	Parameter
        PrintElement element = layoutParameter();
        if (element != null) {
            m_currPage.addElement(element);
            element.setLocation(m_position[AREA_CONTENT]);
            //	GAP
            m_position[AREA_CONTENT].y += element.getHeight() + 5;
        }
        // Process Instance Log (if any):
        element = layoutPInstanceLogs();
        if (element != null) {
            m_currPage.addElement(element);
            element.setLocation(m_position[AREA_CONTENT]);
            //	GAP
            m_position[AREA_CONTENT].y += element.getHeight() + 5;
        }
        //	Table
        if (m_data != null) {
            element = layoutTable(m_format, m_data, 0);
            element.setLocation(m_content.getLocation());
            for (int p = 1; p <= element.getPageCount(); p++) {
                if (p != 1)
                    newPage(true, false);
                m_currPage.addElement(element);
            }
        }
    }
    //
    String pageInfo = String.valueOf(m_pages.size()) + getPageInfo(m_pages.size());
    Env.setContext(m_printCtx, Page.CONTEXT_PAGECOUNT, pageInfo);
    Timestamp now = new Timestamp(System.currentTimeMillis());
    Env.setContext(m_printCtx, Page.CONTEXT_DATE, DisplayType.getDateFormat(DisplayType.Date, m_format.getLanguage()).format(now));
    Env.setContext(m_printCtx, Page.CONTEXT_TIME, DisplayType.getDateFormat(DisplayType.DateTime, m_format.getLanguage()).format(now));
    //
    // Page Background Image
    Image image = null;
    MPrintTableFormat tf = m_format.getTableFormat();
    MTable table = MTable.get(getCtx(), getPrintInfo().getAD_Table_ID());
    if (table.getColumn("IsPrinted") != null && !table.isView()) {
        String tableName = table.getTableName();
        final String sql = "SELECT IsPrinted FROM " + tableName + " WHERE " + tableName + "_ID=?";
        boolean isPrinted = "Y".equals(DB.getSQLValueStringEx(m_TrxName, sql, getPrintInfo().getRecord_ID()));
        if (isPrinted) {
            image = tf.getImageWaterMark();
        }
    } else {
        image = tf.getImage();
    }
    //	Update Page Info
    int pages = m_pages.size();
    for (int i = 0; i < pages; i++) {
        Page page = m_pages.get(i);
        int pageNo = page.getPageNo();
        pageInfo = String.valueOf(pageNo) + getPageInfo(pageNo);
        page.setPageInfo(pageInfo);
        page.setPageCount(pages);
        page.setBackgroundImage(image);
    }
    m_hasLayout = true;
}
Also used : MTable(org.compiere.model.MTable) MPrintTableFormat(org.compiere.print.MPrintTableFormat) Image(java.awt.Image) Timestamp(java.sql.Timestamp) Point(java.awt.Point)

Example 20 with java.awt.image

use of java.awt.image in project adempiere by adempiere.

the class POSInfoProduct method setValuesFromProduct.

/**
	 * Set Values from product
	 * @param productId
	 * @param imageId
	 * @return void
	 */
private void setValuesFromProduct(int productId, BigDecimal quantity, int imageId, int priceListId, int partnerId) {
    if (productId <= 0)
        return;
    //	Refresh Values
    labelPriceName.setText(Msg.parseTranslation(ctx, "@PriceStd@ , @PriceList@ ") + posPanel.getCurSymbol());
    ProductInfo productInfo = new ProductInfo(productId, quantity, imageId, priceListId, partnerId);
    labelValue.setText(productInfo.value);
    //labelPriceLimit.setText(posPanel.getNumberFormat().format(warehousePrice.getPriceLimit()));
    labelPrice.setText(posPanel.getNumberFormat().format(productInfo.priceStd));
    labelPriceList.setText(posPanel.getNumberFormat().format(productInfo.priceList));
    labelName.setText(productInfo.name);
    labelUOMSymbol.setText(productInfo.uomSymbol);
    labelProductCategory.setText(productInfo.productCategoryName);
    labelProductTax.setText(productInfo.productTaxCategory);
    posPanel.updateProductPlaceholder(productInfo.name);
    String description = productInfo.description;
    if (description == null)
        description = "-";
    labelDescription.setText(description.trim());
    //	Set Image
    if (productInfo.imageData != null) {
        try {
            BufferedImage image = ImageIO.read(new ByteArrayInputStream(productInfo.imageData));
            Image imgResized = image.getScaledInstance(BUTTON_SIZE, BUTTON_SIZE, Image.SCALE_SMOOTH);
            buttonImage.setIcon(new ImageIcon(imgResized));
        } catch (IOException e) {
        }
    } else {
        buttonImage.setIcon(null);
        buttonImage.invalidate();
    }
}
Also used : ProductInfo(org.adempiere.pos.service.ProductInfo) ImageIcon(javax.swing.ImageIcon) ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException) Image(java.awt.Image) BufferedImage(java.awt.image.BufferedImage) BufferedImage(java.awt.image.BufferedImage)

Aggregations

Image (java.awt.Image)518 BufferedImage (java.awt.image.BufferedImage)265 ImageIcon (javax.swing.ImageIcon)127 Graphics2D (java.awt.Graphics2D)97 IOException (java.io.IOException)76 File (java.io.File)65 Point (java.awt.Point)53 URL (java.net.URL)51 Graphics (java.awt.Graphics)46 JLabel (javax.swing.JLabel)31 Dimension (java.awt.Dimension)28 Rectangle (java.awt.Rectangle)27 AffineTransform (java.awt.geom.AffineTransform)25 Color (java.awt.Color)24 Test (org.junit.Test)24 RenderedImage (java.awt.image.RenderedImage)21 ArrayList (java.util.ArrayList)21 Toolkit (java.awt.Toolkit)20 IIOImage (javax.imageio.IIOImage)18 MediaTracker (java.awt.MediaTracker)17