public override void paintTo(Graphics2D graphics, int x, int y, int width, int height) { // 現在の描画時のストローク、色を保存しておく Stroke old_stroke = graphics.getStroke(); Color old_color = graphics.getColor(); // 描画用のストロークが初期化してなかったら初期化 if (mStroke == null) { mStroke = new BasicStroke(); } // 枠と背景を描画 paintBackground(graphics, mStroke, x, y, width, height, Color.black, PortUtil.Pink); // デバイス名を書く PortUtil.drawStringEx( (Graphics)graphics, "Amplifier", AppManager.baseFont10, new Rectangle(x, y, width, height), PortUtil.STRING_ALIGN_CENTER, PortUtil.STRING_ALIGN_CENTER); // 描画時のストローク、色を元に戻す graphics.setStroke(old_stroke); graphics.setColor(old_color); }
/// <summary> /// このユニットを指定した位置に描画します。 /// </summary> /// <param name="graphics">描画に使用するグラフィクス</param> /// <param name="x">描画する位置のx座標</param> /// <param name="y">描画する位置のy座標</param> /// <returns>描画された装置図に外接する四角形のサイズ</returns> public virtual void paintTo(Graphics2D graphics, int x, int y, int width, int height) { // 現在の描画時のストローク、色を保存しておく Stroke old_stroke = graphics.getStroke(); Color old_color = graphics.getColor(); // 描画用のストロークが初期化してなかったら初期化 if (mStroke == null) { mStroke = new BasicStroke(); } if (mFont == null) { mFont = new Font("Arial", Font.PLAIN, 10); } // 枠と背景を描画 paintBackground(graphics, mStroke, x, y, width, height, Color.black, PortUtil.Pink); // デバイス名を書く string typename = this.GetType().Name; PortUtil.drawStringEx( (Graphics)graphics, typename, mFont, new Rectangle(x, y, width, height), PortUtil.STRING_ALIGN_CENTER, PortUtil.STRING_ALIGN_CENTER); // 描画時のストローク、色を元に戻す graphics.setStroke(old_stroke); graphics.setColor(old_color); }
public static Image createIconImage(string path_image, string singer_name) { #if DEBUG sout.println("IconParader#createIconImage; path_image=" + path_image); #endif Image ret = null; if (System.IO.File.Exists(path_image)) { System.IO.FileStream fs = null; try { fs = new System.IO.FileStream(path_image, System.IO.FileMode.Open, System.IO.FileAccess.Read); System.Drawing.Image img = System.Drawing.Image.FromStream(fs); ret = new Image(); ret.image = img; } catch (Exception ex) { serr.println("IconParader#createIconImage; ex=" + ex); } finally { if (fs != null) { try { fs.Close(); } catch (Exception ex2) { serr.println("IconParader#createIconImage; ex2=" + ex2); } } } } if (ret == null) { // 画像ファイルが無かったか,読み込みに失敗した場合 // 歌手名が描かれた画像をセットする Image bmp = new Image(); bmp.image = new System.Drawing.Bitmap(ICON_WIDTH, ICON_HEIGHT, System.Drawing.Imaging.PixelFormat.Format24bppRgb); Graphics2D g = new Graphics2D(System.Drawing.Graphics.FromImage(bmp.image)); g.clearRect(0, 0, ICON_WIDTH, ICON_HEIGHT); Font font = new Font(System.Windows.Forms.SystemInformation.MenuFont); PortUtil.drawStringEx( (Graphics)g, singer_name, font, new Rectangle(1, 1, ICON_WIDTH - 2, ICON_HEIGHT - 2), PortUtil.STRING_ALIGN_NEAR, PortUtil.STRING_ALIGN_NEAR); ret = bmp; } return(ret); }
public void receivePaintSignal(Graphics g) { int key_width = AppManager.keyWidth; int width = key_width - 1; int height = mUi.getHeight() - 1; // 背景を塗る g.setColor(PortUtil.DarkGray); g.fillRect(0, 0, width, height); // AutoMaximizeのチェックボックスを描く g.setColor(mWaveViewButtonAutoMaximizeMouseDowned ? PortUtil.Gray : PortUtil.LightGray); g.fillRect(SPACE, SPACE, 16, 16); g.setColor(PortUtil.Gray); g.drawRect(SPACE, SPACE, 16, 16); if (mWaveViewAutoMaximize) { g.setColor(PortUtil.Gray); g.fillRect(SPACE + 3, SPACE + 3, 11, 11); } g.setColor(Color.black); g.setFont(AppManager.baseFont8); g.drawString( "Auto Maximize", SPACE + 16 + SPACE, SPACE + AppManager.baseFont8Height / 2 - AppManager.baseFont8OffsetHeight + 1); // ズーム用ボタンを描く int zoom_button_y = SPACE + 16 + SPACE; int zoom_button_height = height - SPACE - zoom_button_y; Rectangle rc = getButtonBoundsWaveViewZoom(); if (!mWaveViewAutoMaximize) { g.setColor(mWaveViewButtonZoomMouseDowned ? PortUtil.Gray : PortUtil.LightGray); g.fillRect(rc.x, rc.y, rc.width, rc.height); } g.setColor(PortUtil.Gray); g.drawRect(rc.x, rc.y, rc.width, rc.height); g.setColor(mWaveViewAutoMaximize ? PortUtil.Gray : Color.black); rc.y = rc.y + 1; PortUtil.drawStringEx( g, (mWaveViewButtonZoomMouseDowned ? "↑Move Mouse↓" : "Zoom"), AppManager.baseFont9, rc, PortUtil.STRING_ALIGN_CENTER, PortUtil.STRING_ALIGN_CENTER); }
private Image generateAuthorListB(bool show_twitter_id) { int shadow_shift = 2; string font_name = "Arial"; Font font = new Font(font_name, java.awt.Font.PLAIN, FONT_SIZE); Dimension size = Util.measureString("the quick brown fox jumped over the lazy dogs. THE QUICK BROWN FOX JUMPED OVER THE LAZY DOGS. 0123456789", font); int width = this.Width; int height = size.height; //StringFormat sf = new StringFormat(); Image ret = new Image(); ret.image = new System.Drawing.Bitmap((int)width, (int)(40f + m_credit.Length * height * 1.1f), System.Drawing.Imaging.PixelFormat.Format24bppRgb); Graphics2D g = new Graphics2D(System.Drawing.Graphics.FromImage(ret.image)); g.setColor(Color.white); g.fillRect(0, 0, ret.getWidth(null), ret.getHeight(null)); int align = 0; int valign = 0; //sf.Alignment = StringAlignment.Center; Font f = new Font(font_name, java.awt.Font.BOLD, (int)(FONT_SIZE * 1.2f)); if (m_shadow_enablde) { g.setColor(new Color(0, 0, 0, 40)); PortUtil.drawStringEx( g, m_app_name, f, new Rectangle(shadow_shift, shadow_shift, width, height), align, valign); } g.setColor(Color.black); PortUtil.drawStringEx( g, m_app_name, f, new Rectangle(0, 0, width, height), align, valign); for (int i = 0; i < m_credit.Length; i++) { AuthorListEntry itemi = m_credit[i]; Font f2 = new Font(font_name, itemi.getStyle(), FONT_SIZE); string id = show_twitter_id ? itemi.getTwitterID() : ""; if (id == null) { id = ""; } string str = itemi.getName() + (id.Equals("") ? "" : (" (" + id + ")")); if (m_shadow_enablde) { g.setColor(new Color(0, 0, 0, 40)); PortUtil.drawStringEx( g, str, font, new Rectangle(0 + shadow_shift, 40 + (int)(i * height * 1.1) + shadow_shift, width, height), align, valign); } g.setColor(Color.black); PortUtil.drawStringEx( g, str, f2, new Rectangle(0, 40 + (int)(i * height * 1.1), width, height), align, valign); } return(ret); }
/// <summary> /// コンポーネントの描画関数です /// </summary> /// <param name="g"></param> public void paint(Graphics g1) { int width = Width; int height = Height; Rectangle rc = new Rectangle(0, 0, width, height); Graphics2D g = (Graphics2D)g1; // 背景を塗りつぶす g.setStroke(getStrokeDefault()); g.setColor(Color.gray); g.fillRect(rc.x, rc.y, rc.width, rc.height); if (AppManager.skipDrawingWaveformWhenPlaying && AppManager.isPlaying()) { // 左側のボタン部との境界線 g.setColor(mBorderColor); g.drawLine(0, 0, 0, height); g.setColor(Color.black); PortUtil.drawStringEx( g, "(hidden for performance)", AppManager.baseFont8, rc, PortUtil.STRING_ALIGN_CENTER, PortUtil.STRING_ALIGN_CENTER); return; } // スケール線を描く int half_height = height / 2; g.setColor(Color.black); g.drawLine(0, half_height, width, half_height); // 描画コンテキストを用いて波形を描画 int selected = AppManager.getSelected(); WaveDrawContext context = mDrawer[selected - 1]; if (context != null) { if (mAutoMaximize) { context.draw( g, Color.black, rc, AppManager.clockFromXCoord(AppManager.keyWidth), AppManager.clockFromXCoord(AppManager.keyWidth + width), AppManager.getVsqFile().TempoTable, AppManager.mMainWindowController.getScaleX()); } else { context.draw( g, Color.black, rc, AppManager.clockFromXCoord(AppManager.keyWidth), AppManager.clockFromXCoord(AppManager.keyWidth + width), AppManager.getVsqFile().TempoTable, AppManager.mMainWindowController.getScaleX(), mScale); } } // 左側のボタン部との境界線 g.setColor(mBorderColor); g.drawLine(0, 0, 0, height); // ソングポジション int song_pos_x = AppManager.xCoordFromClocks(AppManager.getCurrentClock()) - AppManager.keyWidth; if (0 < song_pos_x) { g.setColor(Color.white); g.setStroke(getStroke2px()); g.drawLine(song_pos_x, 0, song_pos_x, height); } }