Search in sources :

Example 6 with MPrintColor

use of org.compiere.print.MPrintColor in project adempiere by adempiere.

the class MColorSchema method getColor.

//	beforeSave
/**
	 * 	Get Color
	 *	@param percent percent
	 *	@return color
	 */
public Color getColor(int percent) {
    int AD_PrintColor_ID = 0;
    if (percent <= getMark1Percent() || getMark2Percent() == 0)
        AD_PrintColor_ID = getAD_PrintColor1_ID();
    else if (percent <= getMark2Percent() || getMark3Percent() == 0)
        AD_PrintColor_ID = getAD_PrintColor2_ID();
    else if (percent <= getMark3Percent() || getMark4Percent() == 0)
        AD_PrintColor_ID = getAD_PrintColor3_ID();
    else
        AD_PrintColor_ID = getAD_PrintColor4_ID();
    if (AD_PrintColor_ID == 0) {
        if (getAD_PrintColor3_ID() != 0)
            AD_PrintColor_ID = getAD_PrintColor3_ID();
        else if (getAD_PrintColor2_ID() != 0)
            AD_PrintColor_ID = getAD_PrintColor2_ID();
        else if (getAD_PrintColor1_ID() != 0)
            AD_PrintColor_ID = getAD_PrintColor1_ID();
    }
    if (AD_PrintColor_ID == 0)
        return Color.black;
    //
    MPrintColor pc = MPrintColor.get(getCtx(), AD_PrintColor_ID);
    if (pc != null)
        return pc.getColor();
    return Color.black;
}
Also used : MPrintColor(org.compiere.print.MPrintColor)

Example 7 with MPrintColor

use of org.compiere.print.MPrintColor in project adempiere by adempiere.

the class LayoutEngine method createStringElement.

//	includeFormat
/**
	 *	Create String Element
	 *
	 * 	@param content string to be printed
	 * 	@param AD_PrintColor_ID color
	 * 	@param AD_PrintFont_ID font
	 * 	@param maxWidth max width
	 * 	@param maxHeight max height
	 * 	@param isHeightOneLine onle line only
	 * 	@param FieldAlignmentType alignment type (MPrintFormatItem.FIELD_ALIGN_*)
	 *  @param isTranslated if true and content contaiins @variable@, it is dynamically translated during print
	 * 	@return Print Element
	 */
private PrintElement createStringElement(String content, int AD_PrintColor_ID, int AD_PrintFont_ID, int maxWidth, int maxHeight, boolean isHeightOneLine, String FieldAlignmentType, boolean isTranslated) {
    if (content == null || content.length() == 0)
        return null;
    //	Color / Font
    //	default
    Color color = getColor();
    if (AD_PrintColor_ID != 0 && m_printColor.get_ID() != AD_PrintColor_ID) {
        MPrintColor c = MPrintColor.get(getCtx(), AD_PrintColor_ID);
        if (c.getColor() != null)
            color = c.getColor();
    }
    //	default
    Font font = m_printFont.getFont();
    if (AD_PrintFont_ID != 0 && m_printFont.get_ID() != AD_PrintFont_ID) {
        MPrintFont f = MPrintFont.get(AD_PrintFont_ID);
        if (f.getFont() != null)
            font = f.getFont();
    }
    PrintElement e = new StringElement(content, font, color, null, isTranslated);
    e.layout(maxWidth, maxHeight, isHeightOneLine, FieldAlignmentType);
    return e;
}
Also used : MPrintColor(org.compiere.print.MPrintColor) Color(java.awt.Color) MPrintColor(org.compiere.print.MPrintColor) MPrintFont(org.compiere.print.MPrintFont) MPrintFont(org.compiere.print.MPrintFont) Font(java.awt.Font)

Example 8 with MPrintColor

use of org.compiere.print.MPrintColor in project adempiere by adempiere.

the class MTree method getNodeDetail.

/**
	 *  Get Menu Node Details.
	 *  As SQL contains security access, not all nodes will be found
	 *  @param  node_ID     Key of the record
	 *  @param  parent_ID   Parent ID of the record
	 *  @param  seqNo       Sort index
	 *  @param  onBar       Node also on Shortcut bar
	 *  @return Node
	 */
private MTreeNode getNodeDetail(int node_ID, int parent_ID, int seqNo, boolean onBar) {
    MTreeNode retValue = null;
    try {
        //m_nodeRowSet.beforeFirst();
        ArrayList<Integer> nodeList = m_nodeIdMap.get(Integer.valueOf(node_ID));
        int size = nodeList != null ? nodeList.size() : 0;
        int i = 0;
        //while (m_nodeRowSet.next())
        while (i < size) {
            Integer nodeId = nodeList.get(i);
            i++;
            m_nodeRowSet.absolute(nodeId.intValue());
            int node = m_nodeRowSet.getInt(1);
            if (//	search for correct one
            node_ID != node)
                continue;
            //	ID, Name, Description, IsSummary, Action/Color, Value // @Trifon
            int index = 2;
            String name = m_nodeRowSet.getString(index++);
            String description = m_nodeRowSet.getString(index++);
            boolean isSummary = "Y".equals(m_nodeRowSet.getString(index++));
            String actionColor = m_nodeRowSet.getString(index++);
            //	Menu only
            if (getTreeType().equals(TREETYPE_Menu) && !isSummary) {
                int AD_Window_ID = m_nodeRowSet.getInt(index++);
                int AD_Process_ID = m_nodeRowSet.getInt(index++);
                int AD_Form_ID = m_nodeRowSet.getInt(index++);
                int AD_Workflow_ID = m_nodeRowSet.getInt(index++);
                int AD_Task_ID = m_nodeRowSet.getInt(index++);
                int AD_Workbench_ID = m_nodeRowSet.getInt(index++);
                int AD_Browse_ID = m_nodeRowSet.getInt(index++);
                //
                MRole role = MRole.getDefault(getCtx(), false);
                Boolean access = null;
                if (X_AD_Menu.ACTION_Window.equals(actionColor))
                    access = role.getWindowAccess(AD_Window_ID);
                else if (X_AD_Menu.ACTION_Process.equals(actionColor) || X_AD_Menu.ACTION_Report.equals(actionColor))
                    access = role.getProcessAccess(AD_Process_ID);
                else if (X_AD_Menu.ACTION_Form.equals(actionColor))
                    access = role.getFormAccess(AD_Form_ID);
                else if (X_AD_Menu.ACTION_SmartBrowse.equals(actionColor))
                    access = role.getBrowseAccess(AD_Browse_ID);
                else if (X_AD_Menu.ACTION_WorkFlow.equals(actionColor))
                    access = role.getWorkflowAccess(AD_Workflow_ID);
                else if (X_AD_Menu.ACTION_Task.equals(actionColor))
                    access = role.getTaskAccess(AD_Task_ID);
                //
                if (//	rw or ro for Role 
                access != null || //	Menu Window can see all
                m_editable) {
                    retValue = new MTreeNode(node_ID, seqNo, name, description, parent_ID, isSummary, actionColor, onBar, //	menu has no color
                    null);
                }
            } else //	always add
            {
                //	action
                Color color = null;
                if (actionColor != null && !getTreeType().equals(TREETYPE_Menu)) {
                    MPrintColor printColor = MPrintColor.get(getCtx(), actionColor);
                    if (printColor != null)
                        color = printColor.getColor();
                }
                // @Trifon-begin
                if (getTreeType().equals(TREETYPE_ElementValue)) {
                    //					String sourceTableName = getSourceTableName(true); // Uncomment it if you want to see Value for all Tree types
                    //					if ( containsValueColumn( sourceTableName ) ) { // Uncomment it if you want to see Value for all Tree types
                    String value = m_nodeRowSet.getString(index++);
                    name = value + " - " + name;
                }
                // @Trifon-end
                //
                retValue = new MTreeNode(node_ID, seqNo, name, description, parent_ID, isSummary, null, onBar, //	no action
                color);
            }
        }
    } catch (SQLException e) {
        log.log(Level.SEVERE, "", e);
    }
    return retValue;
}
Also used : SQLException(java.sql.SQLException) MPrintColor(org.compiere.print.MPrintColor) Color(java.awt.Color) MPrintColor(org.compiere.print.MPrintColor)

Example 9 with MPrintColor

use of org.compiere.print.MPrintColor in project lar_361 by comitsrl.

the class PosKeyPanel method createCard.

/**
 * @return
 */
private CPanel createCard(int C_POSKeyLayout_ID) {
    // already added
    if (keymap.containsKey(C_POSKeyLayout_ID)) {
        return null;
    }
    CPanel card = new CPanel();
    card.setLayout(new MigLayout("fill, ins 0"));
    MPOSKeyLayout keyLayout = MPOSKeyLayout.get(Env.getCtx(), C_POSKeyLayout_ID);
    Color stdColor = Color.lightGray;
    if (keyLayout.getAD_PrintColor_ID() != 0) {
        MPrintColor color = MPrintColor.get(Env.getCtx(), keyLayout.getAD_PrintColor_ID());
        stdColor = color.getColor();
    }
    Font stdFont = AdempierePLAF.getFont_Field();
    if (keyLayout.getAD_PrintFont_ID() != 0) {
        MPrintFont font = MPrintFont.get(keyLayout.getAD_PrintFont_ID());
        stdFont = font.getFont();
    }
    if (keyLayout.get_ID() == 0)
        return null;
    MPOSKey[] keys = keyLayout.getKeys(false);
    HashMap<Integer, MPOSKey> map = new HashMap<Integer, MPOSKey>(keys.length);
    keymap.put(C_POSKeyLayout_ID, map);
    // Min Columns
    int COLUMNS = 3;
    // Min Rows
    int ROWS = 3;
    int noKeys = keys.length;
    int cols = keyLayout.getColumns();
    if (cols == 0)
        cols = COLUMNS;
    int buttons = 0;
    log.fine("PosSubFunctionKeys.init - NoKeys=" + noKeys + ", Cols=" + cols);
    // Content
    CPanel content = new CPanel(new MigLayout("fill, wrap " + Math.max(cols, 3)));
    String buttonSize = "h 50, w 50, growx, growy, sg button,";
    for (MPOSKey key : keys) {
        if (key.getSubKeyLayout_ID() > 0) {
            CPanel subCard = createCard(key.getSubKeyLayout_ID());
            if (subCard != null)
                add(subCard, Integer.toString(key.getSubKeyLayout_ID()));
        }
        map.put(key.getC_POSKey_ID(), key);
        Color keyColor = stdColor;
        Font keyFont = stdFont;
        StringBuffer buttonHTML = new StringBuffer("<html><p>");
        if (key.getAD_PrintColor_ID() != 0) {
            MPrintColor color = MPrintColor.get(Env.getCtx(), key.getAD_PrintColor_ID());
            keyColor = color.getColor();
        }
        if (key.getAD_PrintFont_ID() != 0) {
            MPrintFont font = MPrintFont.get(key.getAD_PrintFont_ID());
            keyFont = font.getFont();
        }
        buttonHTML.append(key.getName());
        buttonHTML.append("</p></html>");
        log.fine("#" + map.size() + " - " + keyColor);
        CButton button = new CButton(buttonHTML.toString());
        button.setBackground(keyColor);
        button.setFont(keyFont);
        if (key.getAD_Image_ID() != 0) {
            MImage image = MImage.get(Env.getCtx(), key.getAD_Image_ID());
            Icon icon = image.getIcon();
            button.setIcon(icon);
            button.setVerticalTextPosition(SwingConstants.BOTTOM);
            button.setHorizontalTextPosition(SwingConstants.CENTER);
        }
        button.setFocusable(false);
        if (!key.isActive())
            button.setEnabled(false);
        button.setActionCommand(String.valueOf(key.getC_POSKey_ID()));
        button.addActionListener(this);
        String constraints = buttonSize;
        int size = 1;
        if (key.getSpanX() > 1) {
            constraints += "spanx " + key.getSpanX() + ",";
            size = key.getSpanX();
        }
        if (key.getSpanY() > 1) {
            constraints += "spany " + key.getSpanY() + ",";
            size = size * key.getSpanY();
        }
        buttons = buttons + size;
        content.add(button, constraints);
    }
    int rows = Math.max((buttons / cols), ROWS);
    if (buttons % cols > 0)
        rows = rows + 1;
    for (int i = buttons; i < rows * cols; i++) {
        CButton button = new CButton("");
        button.setFocusable(false);
        button.setReadWrite(false);
        content.add(button, buttonSize);
    }
    CScrollPane scroll = new CScrollPane(content);
    // scroll.setPreferredSize(new Dimension( 600 - 20, 400-20));
    card.add(scroll, "growx, growy");
    // increase scrollbar width for touchscreen
    scroll.getVerticalScrollBar().setPreferredSize(new Dimension(30, 0));
    scroll.getHorizontalScrollBar().setPreferredSize(new Dimension(0, 30));
    return card;
}
Also used : HashMap(java.util.HashMap) MPOSKeyLayout(org.compiere.model.MPOSKeyLayout) CScrollPane(org.compiere.swing.CScrollPane) MigLayout(net.miginfocom.swing.MigLayout) Color(java.awt.Color) MPrintColor(org.compiere.print.MPrintColor) CPanel(org.compiere.swing.CPanel) MPrintFont(org.compiere.print.MPrintFont) Dimension(java.awt.Dimension) Font(java.awt.Font) MPrintFont(org.compiere.print.MPrintFont) MImage(org.compiere.model.MImage) MPrintColor(org.compiere.print.MPrintColor) MPOSKey(org.compiere.model.MPOSKey) Icon(javax.swing.Icon) CButton(org.compiere.swing.CButton)

Aggregations

MPrintColor (org.compiere.print.MPrintColor)9 Color (java.awt.Color)8 Font (java.awt.Font)5 HashMap (java.util.HashMap)5 MPrintFont (org.compiere.print.MPrintFont)5 MPOSKey (org.compiere.model.MPOSKey)4 MPOSKeyLayout (org.compiere.model.MPOSKeyLayout)4 MImage (org.compiere.model.MImage)3 Dimension (java.awt.Dimension)2 MigLayout (net.miginfocom.swing.MigLayout)2 Label (org.adempiere.webui.component.Label)2 Panel (org.adempiere.webui.component.Panel)2 PrintDataElement (org.compiere.print.PrintDataElement)2 CButton (org.compiere.swing.CButton)2 CPanel (org.compiere.swing.CPanel)2 CScrollPane (org.compiere.swing.CScrollPane)2 KeyNamePair (org.compiere.util.KeyNamePair)2 ValueNamePair (org.compiere.util.ValueNamePair)2 Image (java.awt.Image)1 Point (java.awt.Point)1