/** * Returns a border instance for a Windows ToolBar * * @return a border used for the toolbar * @since 1.4 */ public static Border getToolBarBorder() { UIDefaults table = UIManager.getLookAndFeelDefaults(); Border toolBarBorder = new WindowsBorders.ToolBarBorder( table.getColor("ToolBar.shadow"), table.getColor("ToolBar.highlight")); return toolBarBorder; }
@Override protected void onPostExecute(String result) { super.onPostExecute(result); Log.d("XMLResult", result); try { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); InputStream xmlData = new ByteArrayInputStream(result.getBytes()); Document xmlDoc = dBuilder.parse(xmlData); ; int redLevel = Integer.parseInt(xmlDoc.getElementsByTagName("r").item(0).getTextContent()); int greenLevel = Integer.parseInt(xmlDoc.getElementsByTagName("g").item(0).getTextContent()); int blueLevel = Integer.parseInt(xmlDoc.getElementsByTagName("b").item(0).getTextContent()); int transition = Integer.parseInt(xmlDoc.getElementsByTagName("lastTransition").item(0).getTextContent()); Integer time = Integer.parseInt(xmlDoc.getElementsByTagName("lastTime").item(0).getTextContent()); uiMan.setRGB(redLevel, greenLevel, blueLevel); uiMan.setTime(time); uiMan.setTransition(transition); } catch (ParserConfigurationException e) { Log.e(e.getClass().toString(), e.getMessage()); } catch (SAXException e) { Log.e(e.getClass().toString(), e.getMessage()); } catch (IOException e) { Log.e(e.getClass().toString(), e.getMessage()); } }
public static class BevelBorder extends AbstractBorder implements UIResource { private Color darkShadow = UIManager.getColor("controlShadow"); private Color lightShadow = UIManager.getColor("controlLtHighlight"); private boolean isRaised; public BevelBorder(boolean isRaised, Color darkShadow, Color lightShadow) { this.isRaised = isRaised; this.darkShadow = darkShadow; this.lightShadow = lightShadow; } public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { g.setColor((isRaised) ? lightShadow : darkShadow); g.drawLine(x, y, x + w - 1, y); // top g.drawLine(x, y + h - 1, x, y + 1); // left g.setColor((isRaised) ? darkShadow : lightShadow); g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1); // bottom g.drawLine(x + w - 1, y + h - 1, x + w - 1, y + 1); // right } public Insets getBorderInsets(Component c, Insets insets) { insets.set(1, 1, 1, 1); return insets; } public boolean isOpaque(Component c) { return true; } }
public void checkDelay() { int pos = mPlayerEngineImpl.getCurPosition(); boolean ret = mCheckDelayTimer.isDelay(pos); if (ret) { mUIManager.showLoadView(true); } else { mUIManager.showLoadView(false); } mCheckDelayTimer.setPos(pos); }
/** * To be called once per frame to render every UI component in the UI manager. This allows the * spritebatch to be passed to the components. * * @param batch The batch to be used to render the UI */ public void render(SpriteBatch batch) { for (int x = 0; x < uiManager.getUIComponents().size(); x++) { uiManager.getUIComponent(x).render(batch, Assets.patch); } if (uiManager.dialogue != null) { uiManager.dialogue.render(batch, Assets.patch); } uiManager.partyMenu.render(batch, Assets.patch); // uiManager.flightMenu.render(batch, Assets.patch); if (uiManager.vista != null) { uiManager.vista.render(batch, Assets.patch); } }
public void paintIcon(Component c, Graphics g, int x, int y) { g.setColor(UIManager.getColor("InternalFrame.resizeIconHighlight")); g.drawLine(0, 11, 11, 0); g.drawLine(4, 11, 11, 4); g.drawLine(8, 11, 11, 8); g.setColor(UIManager.getColor("InternalFrame.resizeIconShadow")); g.drawLine(1, 11, 11, 1); g.drawLine(2, 11, 11, 2); g.drawLine(5, 11, 11, 5); g.drawLine(6, 11, 11, 6); g.drawLine(9, 11, 11, 9); g.drawLine(10, 11, 11, 10); }
/** * Draws the FrameBorder in the given Rect. Calls <b>drawTitleBar</b>, <b>drawLeftBorder</b>, * <b>drawRightBorder</b> and <b>drawBottomBorder</b>. */ public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { if (isActiveFrame()) { frameColor = UIManager.getColor("activeCaptionBorder"); } else { frameColor = UIManager.getColor("inactiveCaptionBorder"); } frameHighlight = frameColor.brighter(); frameShadow = frameColor.darker().darker(); drawTopBorder(c, g, x, y, width, height); drawLeftBorder(c, g, x, y, width, height); drawRightBorder(c, g, x, y, width, height); drawBottomBorder(c, g, x, y, width, height); }
private void refreshIntent(Intent intent) { log.e("refreshIntent"); removeExitMessage(); if (intent != null) { mMediaInfo = DlnaMediaModelFactory.createFromIntent(intent); } mUIManager.updateMediaInfoView(mMediaInfo); mPlayerEngineImpl.playMedia(mMediaInfo); LoaderHelper.syncDownLoadDrawable(mMediaInfo.getAlbumUri(), mHandler, LOAD_DRAWABLE_COMPLETE); mUIManager.showPrepareLoadView(true); mUIManager.showLoadView(false); mUIManager.showControlView(false); }
/*MAIN*/ public static void main(String[] args) { /*Check for commandline arguments*/ if (args.length > 1) { ArgumentParser parser = new ArgumentParser(); parser.parseArguments(args); } else { /*Set the UI to GTK if available */ try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); } catch (Exception e) { System.out.println("Error creating GTK UI"); } /*Run the app*/ SwingUtilities.invokeLater( new Runnable() { public void run() { Crypter cr = new Crypter(); cr.initUI(); cr.setVisible(true); } }); } }
public void onLoadDrawableComplete(Drawable drawable) { if (isDestroy || drawable == null) { return; } mUIManager.updateAlbumPIC(drawable); }
/** * Check if developer changed icon in the UI table. * * @return the icon to use or {@code null} if the current one is to be used */ private Icon getLaFIcon() { // use icon from the UI table if it does not match this one. Icon rv = (Icon) UIManager.getDefaults().get(typeToString(type)); if (rv instanceof VistaMenuItemCheckIcon && ((VistaMenuItemCheckIcon) rv).type == type) { rv = null; } return rv; }
@Override public void onBufferingUpdate(MediaPlayer mp, int percent) { // log.e("onBufferingUpdate --> percen = " + percent + ", curPos = " + mp.getCurrentPosition()); int duration = mPlayerEngineImpl.getDuration(); int time = duration * percent / 100; mUIManager.setSeekbarSecondProgress(time); }
@Override protected String doInBackground(Boolean... params) { Integer redLevel = uiMan.getRed(); Integer greenLevel = uiMan.getGreen(); Integer blueLevel = uiMan.getBlue(); Integer trans = uiMan.getTransition(); Integer time = uiMan.getTime(); if (!params[0]) trans = -1; Log.d( "LightRequest", String.format( "R:%d, G:%d, B:%d, Trans:%d, Time:%d", redLevel, greenLevel, blueLevel, trans, time)); try { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(serviceURI); List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); nameValuePairs.add(new BasicNameValuePair("r", redLevel.toString())); nameValuePairs.add(new BasicNameValuePair("g", greenLevel.toString())); nameValuePairs.add(new BasicNameValuePair("b", blueLevel.toString())); nameValuePairs.add(new BasicNameValuePair("trans", trans.toString())); nameValuePairs.add(new BasicNameValuePair("time", time.toString())); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = httpclient.execute(httppost); HttpEntity entity = response.getEntity(); if (entity != null) { InputStream instream = entity.getContent(); StringBuilder sb = new StringBuilder(); String line; BufferedReader reader = new BufferedReader(new InputStreamReader(instream, "UTF-8")); while ((line = reader.readLine()) != null) { sb.append(line).append("\n"); } String result = sb.toString(); return result; } } catch (ClientProtocolException e) { Log.e(e.getClass().toString(), e.getMessage()); } catch (IOException e) { Log.e(e.getClass().toString(), e.getMessage()); } catch (IllegalArgumentException e) { Log.e(e.getClass().toString(), e.getMessage()); } catch (Exception e) { Log.e(e.getClass().toString(), e.getMessage()); } return "null"; }
protected void openPictureCart(boolean next) { CartBean bean = (CartBean) Engine.getEngine().getBean(UIManager.SCREEN_CARD); if (bean == null) { Engine.getEngine().putBean(UIManager.SCREEN_CARD, bean = new CartBean(getResoursable())); } bean.setProceedCommandName(next); UIManager.getInstance().show(UIManager.SCREEN_SUP_CARD); }
/** * Returns a border instance for a Windows Progress Bar * * @since 1.4 */ public static Border getProgressBarBorder() { UIDefaults table = UIManager.getLookAndFeelDefaults(); Border progressBarBorder = new BorderUIResource.CompoundBorderUIResource( new WindowsBorders.ProgressBarBorder( table.getColor("ProgressBar.shadow"), table.getColor("ProgressBar.highlight")), new EmptyBorder(1, 1, 1, 1)); return progressBarBorder; }
public void show() { WebServiceInteractor ws = App.getCurrentApp().getWebServiceIteractor(); if (ws != null) { if (ws.getTagId() == null || ws.getTagId().length() == 0) { SettingsBean bean = (SettingsBean) UIManager.getInstance().getBean(UIManager.SCREEN_SETTINGS); if (bean == null) { bean = new SettingsBean(App.getCurrentApp().getSettings()); UIManager.getInstance().putBean(UIManager.SCREEN_SETTINGS, bean); } showBusy(null); ws.getTagId(null); ws.getEncryptionTag(null); ws.getBlockList(this); } else { refresh(); } } }
public int getIconWidth() { int width; if (XPStyle.getXP() != null) { // Fix for XP bug where sometimes these sizes aren't updated properly // Assume for now that height is correct and derive width using the // ratio from the uxtheme part width = UIManager.getInt("InternalFrame.titleButtonHeight") - 2; Dimension d = XPStyle.getPartSize(Part.WP_CLOSEBUTTON, State.NORMAL); if (d != null && d.width != 0 && d.height != 0) { width = (int) ((float) width * d.width / d.height); } } else { width = UIManager.getInt("InternalFrame.titleButtonWidth") - 2; } if (XPStyle.getXP() != null) { width -= 2; } return width; }
/** To be called once per frame to render every UI component in the UI manager. */ public void render() { uiBatch.begin(); for (int x = 0; x < uiManager.getUIComponents().size(); x++) { uiManager.getUIComponent(x).render(uiBatch, Assets.patch); } if (uiManager.dialogue != null) { uiManager.dialogue.render(uiBatch, Assets.patch); } if (!uiManager.notifications.isEmpty()) { uiManager.notifications.get(0).render(uiBatch, Assets.patch); } uiManager.partyMenu.render(uiBatch, Assets.patch); uiManager.flightMenu.render(uiBatch, Assets.patch); uiManager.shopMenu.render(uiBatch, Assets.patch); if (uiManager.vista != null) { uiManager.vista.render(uiBatch, Assets.patch); } uiBatch.end(); }
public void commandAction(Command command, Displayable displayable) { super.commandAction(command, displayable); if (command == _exitCommand) { App currentApp = App.getCurrentApp(); currentApp.destroyApp(false); } else if (command == _synchronizeCommand) { System.out.println("MainForm::Synchronize"); if (TagKeeper.getInstance().hasRecords()) App.getCurrentApp().getWebServiceIteractor().uploadTagList(null); else System.out.println("there's nothing to UPLOAD again"); } else if (command == _settingsCommand) { UIManager.getInstance().show(UIManager.SCREEN_SETTINGS); } else if (command == _inviteCommand) { UIManager.getInstance().show(UIManager.SCREEN_CONTACTS); } else if (command == Alert.DISMISS_COMMAND) { refresh(); } }
/** * Implements the standard Icon interface's paintIcon method as the standard synth stub passes * null for the context and this will cause us to not paint any thing, so we override here so that * we can paint the enabled state if no synth context is available */ @Override public void paintIcon(Component c, Graphics g, int x, int y) { Painter painter = (Painter) UIManager.get(prefix + "[Enabled]." + key); if (painter != null) { JComponent jc = (c instanceof JComponent) ? (JComponent) c : null; Graphics2D gfx = (Graphics2D) g; gfx.translate(x, y); painter.paint(gfx, jc, width, height); gfx.translate(-x, -y); } }
@Override protected void onDestroy() { log.e("onDestroy"); isDestroy = true; mUIManager.unInit(); mCheckDelayTimer.stopTimer(); mNetWorkTimer.stopTimer(); mMediaControlBorcastFactory.unregister(); mPlayPosTimer.stopTimer(); mPlayerEngineImpl.exit(); super.onDestroy(); }
public static Border getTableHeaderBorder() { UIDefaults table = UIManager.getLookAndFeelDefaults(); Border tableHeaderBorder = new BorderUIResource.CompoundBorderUIResource( new BasicBorders.ButtonBorder( table.getColor("Table.shadow"), table.getColor("Table.darkShadow"), table.getColor("Table.light"), table.getColor("Table.highlight")), new BasicBorders.MarginBorder()); return tableHeaderBorder; }
public static Border getInternalFrameBorder() { UIDefaults table = UIManager.getLookAndFeelDefaults(); Border internalFrameBorder = new BorderUIResource.CompoundBorderUIResource( BorderFactory.createBevelBorder( BevelBorder.RAISED, table.getColor("InternalFrame.borderColor"), table.getColor("InternalFrame.borderHighlight"), table.getColor("InternalFrame.borderDarkShadow"), table.getColor("InternalFrame.borderShadow")), new WindowsBorders.InternalFrameLineBorder( table.getColor("InternalFrame.activeBorderColor"), table.getColor("InternalFrame.inactiveBorderColor"), table.getInt("InternalFrame.borderWidth"))); return internalFrameBorder; }
private void installTheme() { // This is not the normal way to do this. // Usually you load a theme from a file. /* */ try { Resources r = Resources.open("/res/javaTheme.res"); UIManager.getInstance().setThemeProps(r.getTheme("javaTheme")); // Resources r = Resources.open("/res/businessTheme.res"); // UIManager.getInstance().setThemeProps(r.getTheme("businessTheme")); } catch (IOException ioe) { System.out.println("Couldn't load theme."); } /*UIManager uim = UIManager.getInstance(); Hashtable ht = new Hashtable(); ht.put("sel#" + Style.BG_COLOR, "d0d0ed"); ht.put(Style.BG_COLOR, "ffffff"); ht.put(Style.FG_COLOR, "000056"); uim.setThemeProps(ht); */ }
protected void build() { jepMessage = new JEditorPane("text/html", ""); jepMessage.setOpaque(false); jepMessage.setEditable(false); jepMessage.addHyperlinkListener(this); Font f = UIManager.getFont("Label.font"); StyleSheet ss = new StyleSheet(); String rule = MessageFormat.format( "font-family: ''{0}'';font-size: {1,number}pt; font-weight: {2}; font-style: {3}", f.getName(), f.getSize(), f.isBold() ? "bold" : "normal", f.isItalic() ? "italic" : "normal"); rule = "body {" + rule + "}"; rule = MessageFormat.format( "font-family: ''{0}'';font-size: {1,number}pt; font-weight: {2}; font-style: {3}", f.getName(), f.getSize(), "bold", f.isItalic() ? "italic" : "normal"); rule = "strong {" + rule + "}"; ss.addRule(rule); ss.addRule("a {text-decoration: underline; color: blue}"); HTMLEditorKit kit = new HTMLEditorKit(); kit.setStyleSheet(ss); jepMessage.setEditorKit(kit); setLayout(new BorderLayout()); add(jepMessage, BorderLayout.CENTER); lblWarning = new JLabel(""); lblWarning.setVisible(false); lblWarning.setIcon(ImageProvider.get("warning-small.png")); lblWarning.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JPanel pnl = new JPanel(new BorderLayout()); pnl.add(lblWarning, BorderLayout.NORTH); add(pnl, BorderLayout.WEST); }
@Override public boolean onError(MediaPlayer mp, int what, int extra) { mUIManager.showPlayErrorTip(); log.e("onError what = " + what + ", extra = " + extra); return false; }
/** * This method is not being used to paint menu item since 6.0 This code left for compatibility * only. Do not use or override it, this will not cause any visible effect. */ public static void paintMenuItem( Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem b = (JMenuItem) c; ButtonModel model = b.getModel(); Dimension size = b.getSize(); Insets i = c.getInsets(); Rectangle viewRect = new Rectangle(size); viewRect.x += i.left; viewRect.y += i.top; viewRect.width -= (i.right + viewRect.x); viewRect.height -= (i.bottom + viewRect.y); Rectangle iconRect = new Rectangle(); Rectangle textRect = new Rectangle(); Rectangle acceleratorRect = new Rectangle(); Rectangle checkRect = new Rectangle(); Rectangle arrowRect = new Rectangle(); Font holdf = g.getFont(); Font f = c.getFont(); g.setFont(f); FontMetrics fm = SwingUtilities2.getFontMetrics(c, g, f); FontMetrics fmAccel = SwingUtilities2.getFontMetrics(c, g, UIManager.getFont("MenuItem.acceleratorFont")); if (c.isOpaque()) { if (model.isArmed() || (c instanceof JMenu && model.isSelected())) { g.setColor(background); } else { g.setColor(c.getBackground()); } g.fillRect(0, 0, size.width, size.height); } // get Accelerator text KeyStroke accelerator = b.getAccelerator(); String acceleratorText = ""; if (accelerator != null) { int modifiers = accelerator.getModifiers(); if (modifiers > 0) { acceleratorText = KeyEvent.getKeyModifiersText(modifiers); acceleratorText += "+"; } acceleratorText += KeyEvent.getKeyText(accelerator.getKeyCode()); } // layout the text and icon String text = layoutMenuItem( c, fm, b.getText(), fmAccel, acceleratorText, b.getIcon(), checkIcon, arrowIcon, b.getVerticalAlignment(), b.getHorizontalAlignment(), b.getVerticalTextPosition(), b.getHorizontalTextPosition(), viewRect, iconRect, textRect, acceleratorRect, checkRect, arrowRect, b.getText() == null ? 0 : defaultTextIconGap, defaultTextIconGap); // Paint the Check Color holdc = g.getColor(); if (checkIcon != null) { if (model.isArmed() || (c instanceof JMenu && model.isSelected())) g.setColor(foreground); checkIcon.paintIcon(c, g, checkRect.x, checkRect.y); g.setColor(holdc); } // Paint the Icon if (b.getIcon() != null) { Icon icon; if (!model.isEnabled()) { icon = b.getDisabledIcon(); } else if (model.isPressed() && model.isArmed()) { icon = b.getPressedIcon(); if (icon == null) { // Use default icon icon = b.getIcon(); } } else { icon = b.getIcon(); } if (icon != null) { icon.paintIcon(c, g, iconRect.x, iconRect.y); } } // Draw the Text if (text != null && !text.equals("")) { // Once BasicHTML becomes public, use BasicHTML.propertyKey // instead of the hardcoded string below! View v = (View) c.getClientProperty("html"); if (v != null) { v.paint(g, textRect); } else { int mnemIndex = b.getDisplayedMnemonicIndex(); if (!model.isEnabled()) { // *** paint the text disabled g.setColor(b.getBackground().brighter()); SwingUtilities2.drawStringUnderlineCharAt( b, g, text, mnemIndex, textRect.x, textRect.y + fmAccel.getAscent()); g.setColor(b.getBackground().darker()); SwingUtilities2.drawStringUnderlineCharAt( b, g, text, mnemIndex, textRect.x - 1, textRect.y + fmAccel.getAscent() - 1); } else { // *** paint the text normally if (model.isArmed() || (c instanceof JMenu && model.isSelected())) { g.setColor(foreground); } else { g.setColor(b.getForeground()); } SwingUtilities2.drawStringUnderlineCharAt( b, g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent()); } } } // Draw the Accelerator Text if (acceleratorText != null && !acceleratorText.equals("")) { // Get the maxAccWidth from the parent to calculate the offset. int accOffset = 0; Container parent = b.getParent(); if (parent != null && parent instanceof JComponent) { JComponent p = (JComponent) parent; Integer maxValueInt = (Integer) p.getClientProperty(MotifGraphicsUtils.MAX_ACC_WIDTH); int maxValue = maxValueInt != null ? maxValueInt.intValue() : acceleratorRect.width; // Calculate the offset, with which the accelerator texts will be drawn with. accOffset = maxValue - acceleratorRect.width; } g.setFont(UIManager.getFont("MenuItem.acceleratorFont")); if (!model.isEnabled()) { // *** paint the acceleratorText disabled g.setColor(b.getBackground().brighter()); SwingUtilities2.drawString( c, g, acceleratorText, acceleratorRect.x - accOffset, acceleratorRect.y + fm.getAscent()); g.setColor(b.getBackground().darker()); SwingUtilities2.drawString( c, g, acceleratorText, acceleratorRect.x - accOffset - 1, acceleratorRect.y + fm.getAscent() - 1); } else { // *** paint the acceleratorText normally if (model.isArmed() || (c instanceof JMenu && model.isSelected())) { g.setColor(foreground); } else { g.setColor(b.getForeground()); } SwingUtilities2.drawString( c, g, acceleratorText, acceleratorRect.x - accOffset, acceleratorRect.y + fmAccel.getAscent()); } } // Paint the Arrow if (arrowIcon != null) { if (model.isArmed() || (c instanceof JMenu && model.isSelected())) g.setColor(foreground); if (!(b.getParent() instanceof JMenuBar)) arrowIcon.paintIcon(c, g, arrowRect.x, arrowRect.y); } g.setColor(holdc); g.setFont(holdf); }
public void seek(int pos) { isSeekComplete = false; mPlayerEngineImpl.skipTo(pos); mUIManager.setSeekbarProgress(pos); }
public void refreshCurPos() { int pos = mPlayerEngineImpl.getCurPosition(); mUIManager.setSeekbarProgress(pos); DLNAGenaEventBrocastFactory.sendSeekEvent(mContext, pos); }
public void refreshSpeed() { if (mUIManager.isLoadViewShow()) { float speed = CommonUtil.getSysNetworkDownloadSpeed(); mUIManager.setSpeed(speed); } }