{ val bounds = getFont.getStringBounds(template, font_render_context) val dim = new Dimension(bounds.getWidth.toInt, bounds.getHeight.toInt)
setPreferredSize(dim)
setMaximumSize(dim)
}
def progress_foreground: Color = jEdit.getColorProperty("view.status.memory.foreground") def progress_background: Color = jEdit.getColorProperty("view.status.memory.background")
/* paint */
def get_status: (String, Double)
overridedef paintComponent(gfx: Graphics): Unit = { super.paintComponent(gfx)
val insets = new Insets(0, 0, 0, 0)
val width = getWidth - insets.left - insets.right val height = getHeight - insets.top - insets.bottom - 1
val (text, fraction) = get_status val width2 = (width * fraction).toInt
val text_bounds = gfx.getFont.getStringBounds(text, font_render_context) val text_x = insets.left + ((width - text_bounds.getWidth).toInt / 2) val text_y = (insets.top + line_metrics.getAscent).toInt
privatedef update_status(new_status: Java_Statistics.Memory_Status): Unit = { if (status != new_status) {
status = new_status
repaint()
}
}
/* timer */
privateval timer = new Timer(500, new ActionListener { overridedef actionPerformed(e: ActionEvent): Unit =
update_status(Java_Statistics.memory_status())
})
overridedef addNotify(): Unit = { super.addNotify()
timer.start()
}
overridedef removeNotify(): Unit = { super.removeNotify()
timer.stop()
}
/* action */
setToolTipText("Java heap memory (double-click for monitor application)")
class Java_Factory extends StatusWidgetFactory { overridedef getWidget(view: View): Widget = new Widget { overridedef getComponent: JComponent = new Java_GUI(view) }
}
/** ML **/
class ML_GUI(view: View) extends GUI(view) { /* component state -- owned by GUI thread */
privatevar status = ML_Statistics.memory_status(Nil)
def get_status: (String, Double) =
status.gc_progress match { case Some(p) => ("ML cleanup", 1.0 - p) case None => val text = "ML: " + status.heap_used.MiB.round + "/" + status.heap_size.MiB.round + "MiB"
(text, status.heap_used_fraction)
}
privatedef update_status(new_status: ML_Statistics.Memory_Status): Unit = { if (status != new_status) {
status = new_status
repaint()
}
}
/* main */
privateval main =
Session.Consumer[Session.Runtime_Statistics](getClass.getName) { case stats => val status = ML_Statistics.memory_status(stats.props)
GUI_Thread.later { update_status(status) }
}
overridedef addNotify(): Unit = { super.addNotify()
PIDE.session.runtime_statistics += main
}
overridedef removeNotify(): Unit = { super.removeNotify()
PIDE.session.runtime_statistics -= main
}
/* action */
setToolTipText("ML heap memory (double-click for monitor panel)")
class ML_Factory extends StatusWidgetFactory { overridedef getWidget(view: View): Widget = new Widget { overridedef getComponent: JComponent = new ML_GUI(view) }
}
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.15Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.