本文整理汇总了Scala中java.awt.Font类的典型用法代码示例。如果您正苦于以下问题:Scala Font类的具体用法?Scala Font怎么用?Scala Font使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Font类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: GameOver
//设置package包名称以及导入依赖的类
package com.alvinalexander
import java.awt.Color
import java.awt.Font
package object bubbles {
val SCREEN_HEIGHT = 600
val SCREEN_WIDTH = 800
val NUM_CIRCLES = 10
val CIRCLE_DIAMETER = 40
val SPACE_BETWEEN_CIRCLES = 72
val INITIAL_SPACE = 40
val CIRCLE_FONT = new Font("Sans Serif", Font.BOLD, 22)
val CIRCLE_FONT_PADDING_X = 13
val CIRCLE_FONT_PADDING_Y = 28
val APPLICATION_NAME = "Akka Actors 'Kill The Characters' Game"
val ACTOR_SYSTEM_NAME = "TinyBubbles"
val BUBBLE_PANEL_ACTOR_NAME = "bubblePanelActor"
val MAIN_FRAME_ACTOR_NAME = "mainFrameActor"
val KEY_LISTENER_ACTOR_NAME = "keyListenerActor"
val PLAY_SOUND_ACTOR_NAME = "playSoundActor"
val ACTOR_MANAGER_NAME = "actorManager"
val COLORS = Array(
(Color.WHITE, Color.BLUE),
(Color.BLACK, Color.CYAN),
(Color.BLACK, Color.GREEN),
(Color.BLACK, Color.LIGHT_GRAY),
(Color.WHITE, Color.MAGENTA),
(Color.WHITE, Color.ORANGE),
(Color.WHITE, Color.PINK),
(Color.WHITE, Color.RED),
(Color.BLACK, Color.WHITE),
(Color.BLACK, Color.YELLOW))
// actor messages
case object GameOver
}
示例2: PremiseView
//设置package包名称以及导入依赖的类
package ui.premiseView
import java.awt.{Toolkit, BorderLayout, Dimension, Font}
import javax.swing._
class PremiseView(premise: String = "") extends JFrame {
private val premisePanel = new JPanel()
private var graphPanel: ResultPanel = null
config
configInput
start
private def start = {
val screenSize = Toolkit.getDefaultToolkit.getScreenSize
setSize(new Dimension(
(screenSize.getWidth * .60).toInt,
(screenSize.getHeight * .60).toInt))
setLocationRelativeTo(null)
setVisible(true)
}
private def config = {
setLayout(new BorderLayout())
add(premisePanel, BorderLayout.NORTH)
setIconImage(new ImageIcon("resources/icon.png").getImage)
setTitle(s"Premise View")
}
private def configInput = {
val premiseLabel = new JLabel()
val font = premiseLabel.getFont()
val boldFont = new Font(font.getFontName(), Font.BOLD, font.getSize())
premiseLabel.setFont(boldFont)
premiseLabel.setText(premise)
premisePanel.add(premiseLabel)
graphPanel = new ResultPanel(premise)
getContentPane.add(graphPanel)
getContentPane.repaint()
getContentPane.validate()
}
}
示例3: Fonte
//设置package包名称以及导入依赖的类
package jerimum
import br.edu.ifrn.potigol.Potigolutil.{ Inteiro, Real, Texto }
import java.awt.Font
object Fonte {
}
case class Fonte(tamanho: Inteiro) {
private[this] val font = new Font("Dialog", Font.BOLD, tamanho);
def desenhe_centralizado(msg: Texto, x: Real, y: Real, z: Inteiro, c: Cor) = {
Desenho.incluir(z, g => {
g.setColor(c.color)
g.setFont(font)
val largura = g.getFontMetrics.stringWidth(msg)
val altura = g.getFontMetrics.getHeight
g.drawString(msg, x.toInt - largura / 2, y.toInt - altura / 2)
})
}
def desenhe(msg: Texto, x: Real, y: Real, z: Inteiro, c: Cor) = {
Desenho.incluir(z, g => {
g.setColor(c.color)
g.setFont(font)
g.drawString(msg, x.toInt, y.toInt)
})
}
}
示例4: JawaSyntaxHighlighter
//设置package包名称以及导入依赖的类
package org.argus.cit.intellij.jawa.highlighter
import java.awt.Font
import java.util
import com.intellij.lexer.Lexer
import com.intellij.openapi.editor.colors.TextAttributesKey
import com.intellij.openapi.editor.markup.TextAttributes
import com.intellij.openapi.fileTypes.SyntaxHighlighterBase
import com.intellij.psi.tree.IElementType
import org.argus.cit.intellij.jawa.lang.lexer.{JawaLexerAdapter, JawaTokenTypes}
object JawaSyntaxHighlighter extends SyntaxHighlighterBase {
final val BOLD = new TextAttributes(null, null, null, null, Font.BOLD)
final val ITALIC = new TextAttributes(null, null, null, null, Font.ITALIC)
final val BOLD_ITALIC = TextAttributes.merge(BOLD, ITALIC)
private final val ATTRIBUTES: util.HashMap[IElementType, TextAttributesKey] = new util.HashMap
SyntaxHighlighterBase.fillMap(ATTRIBUTES, JawaTokenTypes.LINE_COMMENTS, DefaultHighlighter.LINE_COMMENT)
SyntaxHighlighterBase.fillMap(ATTRIBUTES, JawaTokenTypes.BLOCK_COMMENTS, DefaultHighlighter.BLOCK_COMMENT)
SyntaxHighlighterBase.fillMap(ATTRIBUTES, JawaTokenTypes.DOC_COMMENTS, DefaultHighlighter.DOC_COMMENT)
SyntaxHighlighterBase.fillMap(ATTRIBUTES, JawaTokenTypes.KEYWORDS, DefaultHighlighter.KEYWORD)
SyntaxHighlighterBase.fillMap(ATTRIBUTES, JawaTokenTypes.NUMBERS, DefaultHighlighter.NUMBER)
SyntaxHighlighterBase.fillMap(ATTRIBUTES, JawaTokenTypes.STRINGS, DefaultHighlighter.STRING)
SyntaxHighlighterBase.fillMap(ATTRIBUTES, JawaTokenTypes.BRACKETS, DefaultHighlighter.BRACKETS)
SyntaxHighlighterBase.fillMap(ATTRIBUTES, JawaTokenTypes.BRACES, DefaultHighlighter.BRACES)
SyntaxHighlighterBase.fillMap(ATTRIBUTES, JawaTokenTypes.PARENTESES, DefaultHighlighter.PARENTHESES)
SyntaxHighlighterBase.fillMap(ATTRIBUTES, JawaTokenTypes.ASSIGN_OP, DefaultHighlighter.ASSIGN)
SyntaxHighlighterBase.fillMap(ATTRIBUTES, JawaTokenTypes.SEMICOLON, DefaultHighlighter.SEMICOLON)
SyntaxHighlighterBase.fillMap(ATTRIBUTES, JawaTokenTypes.DOT, DefaultHighlighter.DOT)
SyntaxHighlighterBase.fillMap(ATTRIBUTES, JawaTokenTypes.COMMA, DefaultHighlighter.COMMA)
SyntaxHighlighterBase.fillMap(ATTRIBUTES, JawaTokenTypes.BAD_CHARACTER, DefaultHighlighter.BAD_CHARACTER)
SyntaxHighlighterBase.fillMap(ATTRIBUTES, JawaTokenTypes.ANNOTATION, DefaultHighlighter.ANNOTATION)
override def getTokenHighlights(iElementType: IElementType): Array[TextAttributesKey] = {
SyntaxHighlighterBase.pack(ATTRIBUTES.get(iElementType))
}
override def getHighlightingLexer: Lexer = new JawaLexerAdapter
}
示例5: CountByRatingChart
//设置package包名称以及导入依赖的类
package org.sparksamples
import scala.collection.immutable.ListMap
import scalax.chart.module.ChartFactories
import java.awt.Font
import org.jfree.chart.axis.CategoryLabelPositions
object CountByRatingChart {
def main(args: Array[String]) {
val rating_data_raw = Util.sc.textFile("../../data/ml-100k/u.data")
val rating_data = rating_data_raw.map(line => line.split("\t"))
val ratings = rating_data.map(fields => fields(2).toInt)
val ratings_count = ratings.countByValue()
val sorted = ListMap(ratings_count.toSeq.sortBy(_._1):_*)
val ds = new org.jfree.data.category.DefaultCategoryDataset
sorted.foreach{ case (k,v) => ds.addValue(v,"Rating Values", k)}
val chart = ChartFactories.BarChart(ds)
val font = new Font("Dialog", Font.PLAIN,5);
chart.peer.getCategoryPlot.getDomainAxis().
setCategoryLabelPositions(CategoryLabelPositions.UP_90);
chart.peer.getCategoryPlot.getDomainAxis.setLabelFont(font)
chart.show()
Util.sc.stop()
}
}
开发者ID:PacktPublishing,项目名称:Machine-Learning-with-Spark-Second-Edition,代码行数:31,代码来源:CountByRatingChart.scala
示例6: UserOccupationChart
//设置package包名称以及导入依赖的类
package org.sparksamples
import scala.collection.immutable.ListMap
import scalax.chart.module.ChartFactories
import java.awt.Font
import org.jfree.chart.axis.CategoryLabelPositions
object UserOccupationChart {
def main(args: Array[String]) {
val user_data = Util.getUserData()
val user_fields = user_data.map(l => l.split("\\|"))
val count_by_occupation = user_fields.map( fields => (fields(3), 1)).
reduceByKey( (x, y) => x + y).collect()
println(count_by_occupation)
val sorted = ListMap(count_by_occupation.toSeq.sortBy(_._2):_*)
val ds = new org.jfree.data.category.DefaultCategoryDataset
sorted.foreach{ case (k,v) => ds.addValue(v,"UserAges", k)}
val chart = ChartFactories.BarChart(ds)
val font = new Font("Dialog", Font.PLAIN,5);
chart.peer.getCategoryPlot.getDomainAxis().
setCategoryLabelPositions(CategoryLabelPositions.UP_90);
chart.peer.getCategoryPlot.getDomainAxis.setLabelFont(font)
chart.show()
Util.sc.stop()
}
}
开发者ID:PacktPublishing,项目名称:Machine-Learning-with-Spark-Second-Edition,代码行数:32,代码来源:UserOccupationChart.scala
示例7:
//设置package包名称以及导入依赖的类
package org.sparksamples
import java.awt.Font
import org.apache.spark.SparkConf
import org.apache.spark.sql.SparkSession
import org.apache.spark.sql.types.{IntegerType, StructField, StructType}
import org.jfree.chart.axis.CategoryLabelPositions
import scalax.chart.module.ChartFactories
val customSchema = StructType(Array(
StructField("user_id", IntegerType, true),
StructField("movie_id", IntegerType, true),
StructField("rating", IntegerType, true),
StructField("timestamp", IntegerType, true)))
val spConfig = (new SparkConf).setMaster("local").setAppName("SparkApp")
val spark = SparkSession
.builder()
.appName("SparkRatingData").config(spConfig)
.getOrCreate()
val rating_df = spark.read.format("com.databricks.spark.csv")
.option("delimiter", "\t").schema(customSchema)
.load("../../data/ml-100k/u.data")
val rating_df_count = rating_df.groupBy("rating").count().sort("rating")
//val rating_df_count_sorted = rating_df_count.sort("count")
rating_df_count.show()
val rating_df_count_collection = rating_df_count.collect()
val ds = new org.jfree.data.category.DefaultCategoryDataset
val mx = scala.collection.immutable.ListMap()
for( x <- 0 until rating_df_count_collection.length) {
val occ = rating_df_count_collection(x)(0)
val count = Integer.parseInt(rating_df_count_collection(x)(1).toString)
ds.addValue(count,"UserAges", occ.toString)
}
//val sorted = ListMap(ratings_count.toSeq.sortBy(_._1):_*)
//val ds = new org.jfree.data.category.DefaultCategoryDataset
//sorted.foreach{ case (k,v) => ds.addValue(v,"Rating Values", k)}
val chart = ChartFactories.BarChart(ds)
val font = new Font("Dialog", Font.PLAIN,5);
chart.peer.getCategoryPlot.getDomainAxis().
setCategoryLabelPositions(CategoryLabelPositions.UP_90);
chart.peer.getCategoryPlot.getDomainAxis.setLabelFont(font)
chart.show()
Util.sc.stop()
}
}
开发者ID:PacktPublishing,项目名称:Machine-Learning-with-Spark-Second-Edition,代码行数:59,代码来源:CountByRatingChart.scala
示例8: UserOccupationChart
//设置package包名称以及导入依赖的类
package org.sparksamples
import java.awt.Font
import org.jfree.chart.axis.CategoryLabelPositions
import scalax.chart.module.ChartFactories
object UserOccupationChart {
def main(args: Array[String]) {
val userDataFrame = Util.getUserFieldDataFrame()
val occupation = userDataFrame.select("occupation")
val occupation_groups = userDataFrame.groupBy("occupation").count()
//occupation_groups.show()
val occupation_groups_sorted = occupation_groups.sort("count")
occupation_groups_sorted.show()
val occupation_groups_collection = occupation_groups_sorted.collect()
val ds = new org.jfree.data.category.DefaultCategoryDataset
val mx = scala.collection.immutable.ListMap()
for( x <- 0 until occupation_groups_collection.length) {
val occ = occupation_groups_collection(x)(0)
val count = Integer.parseInt(occupation_groups_collection(x)(1).toString)
ds.addValue(count,"UserAges", occ.toString)
}
val chart = ChartFactories.BarChart(ds)
val font = new Font("Dialog", Font.PLAIN,5);
chart.peer.getCategoryPlot.getDomainAxis().
setCategoryLabelPositions(CategoryLabelPositions.UP_90);
chart.peer.getCategoryPlot.getDomainAxis.setLabelFont(font)
chart.show()
Util.sc.stop()
}
}
开发者ID:PacktPublishing,项目名称:Machine-Learning-with-Spark-Second-Edition,代码行数:40,代码来源:UserOccupationChart.scala
示例9: PlotLogData
//设置package包名称以及导入依赖的类
package org.sparksamples
//import org.sparksamples.Util
//import _root_.scalax.chart.ChartFactories
import java.awt.Font
import org.jfree.chart.axis.CategoryLabelPositions
import scala.collection.immutable.ListMap
import scalax.chart.module.ChartFactories
object PlotLogData {
def main(args: Array[String]) {
val records = Util.getRecords()._1
val records_x = records.map(r => Math.log(r(r.length -1).toDouble))
var records_int = new Array[Int](records_x.collect().length)
print(records_x.first())
val records_collect = records_x.collect()
for (i <- 0 until records_collect.length){
records_int(i) = records_collect(i).toInt
}
val min_1 = records_int.min
val max_1 = records_int.max
val min = min_1.toFloat
val max = max_1.toFloat
val bins = 10
val step = (max/bins).toFloat
var mx = Map(0.0.toString -> 0)
for (i <- step until (max + step) by step) {
mx += (i.toString -> 0);
}
for(i <- 0 until records_collect.length){
for (j <- 0.0 until (max + step) by step) {
if(records_int(i) >= (j) && records_int(i) < (j + step)){
mx = mx + (j.toString -> (mx(j.toString) + 1))
}
}
}
val mx_sorted = ListMap(mx.toSeq.sortBy(_._1.toFloat):_*)
val ds = new org.jfree.data.category.DefaultCategoryDataset
var i = 0
mx_sorted.foreach{ case (k,v) => ds.addValue(v,"", k)}
val chart = ChartFactories.BarChart(ds)
val font = new Font("Dialog", Font.PLAIN,4);
chart.peer.getCategoryPlot.getDomainAxis().
setCategoryLabelPositions(CategoryLabelPositions.UP_90);
chart.peer.getCategoryPlot.getDomainAxis.setLabelFont(font)
chart.show()
Util.sc.stop()
}
}
开发者ID:PacktPublishing,项目名称:Machine-Learning-with-Spark-Second-Edition,代码行数:62,代码来源:PlotLogData.scala
示例10: Pi
//设置package包名称以及导入依赖的类
package com.loopfor.pi
import java.awt.{AlphaComposite, Color, Font, RenderingHints}
import java.awt.image.BufferedImage
import java.io.File
import javax.imageio.ImageIO
import scala.io.Source
object Pi {
private val Rows = 500
private val Cols = 2000
private val Watermark = "?"
def main(args: Array[String]): Unit = {
val lines = Source.fromFile("pi-formatted.txt").getLines
// Calculate width and height of single row of digits.
val font = new Font("Source Code Pro", Font.PLAIN, 10)
var gr = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB).createGraphics()
val (width, height) = try {
gr.setFont(font)
val metrics = gr.getFontMetrics
(metrics.stringWidth("0" * Cols), metrics.getHeight * Rows)
} finally
gr.dispose()
val image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB)
// Render all digits.
gr = image.createGraphics()
gr.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY)
gr.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)
gr.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY)
gr.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE)
gr.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON)
gr.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR)
gr.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY)
gr.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE)
gr.setFont(font)
gr.setColor(Color.BLACK)
lines.foldLeft(0) { (r, line) =>
gr.drawString(line, 0, (r + 1) * gr.getFontMetrics.getAscent)
r + 1
}
// Render the Pi symbol overlay.
gr.setFont(new Font("Symbol", Font.PLAIN, 6000))
gr.setColor(Color.BLUE)
gr.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.8F))
val bounds = gr.getFontMetrics.getStringBounds(Watermark, gr)
val x = (width - bounds.getWidth) / 2
val y = -bounds.getY - (height - bounds.getHeight) / 2
gr.drawString(Watermark, x.toInt, y.toInt)
gr.dispose()
ImageIO.write(image, "PNG", new File("pi-poster.png"))
}
}
示例11: ChangeModes
//设置package包名称以及导入依赖的类
package gui
import java.awt.Font
import colors.ThemeSettings._
import de.sciss.syntaxpane.DefaultSyntaxKit
import textengine.Cluster
object ChangeModes {
def changeFontsToSliderValue(newSize: Int, cluster: Cluster) = {
cluster.editor.font =
new Font(cluster.vars.font_style, java.awt.Font.PLAIN, newSize)
cluster.info.text = s"Font size is set to $newSize"
newSize
}
def goToEditorMode(cluster: Cluster) = {
val txt = cluster.editor.text
val syntaxConfig = DefaultSyntaxKit.getConfig(classOf[DefaultSyntaxKit])
syntaxConfig.put(
"DefaultFont",
cluster.vars.font_style + " " + cluster.vars.font_size.toString)
cluster.editor.contentType = "text/" + cluster.const.AVAILABLE_SYNTAX(
"Scala")
cluster.editor.text = txt
setThemeForEditorMode(cluster)
cluster.vars.mode = false
cluster.info.text = "You are now in the text editor mode"
}
def goToNotepadMode(cluster: Cluster) = {
val txt = cluster.editor.text
cluster.editor.contentType = "text/plain"
setEditorTheme(cluster, cluster.vars.theme)
cluster.editor.text = txt
cluster.vars.mode = true
cluster.info.text = "You are now in the notepad mode"
}
def changeSyntax(lang: String, cluster: Cluster) = {
goToEditorMode(cluster)
val availableSyntax = cluster.const.AVAILABLE_SYNTAX
val txt = cluster.editor.text
if (availableSyntax.keys.exists(_ == lang)) {
cluster.editor.contentType = "text/" + availableSyntax(lang)
cluster.editor.text = txt
cluster.info.text = s"You updated the syntax to $lang"
} else {
cluster.info.text = s"Can not find syntax pack for $lang"
}
}
}
示例12: Misc
//设置package包名称以及导入依赖的类
// scalac -deprecation Misc.scala
import scala.annotation.unchecked._
import java.awt.Font
import java.awt.Font._
object Misc {
@deprecated(message = "Use factorial(n: BigInt) instead")
def factorial(n: Int): Int = if (n <= 0) 1 else n * factorial(n - 1)
// Recursive call causes a deprecation warning
def draw(@deprecatedName('sz) size: Int, style: Int = PLAIN) {
val font = new Font("Dialog", style, size)
// ...
}
draw(sz = 12)
def process(lst: List[Int]) =
(lst: @unchecked) match {
case head :: tail => head + tail.length
}
}
trait Comparable[-T] extends
java.lang.Comparable[T @uncheckedVariance]
示例13: WindowGraph
//设置package包名称以及导入依赖的类
package aug.script.test
import java.awt.Font
import aug.script.framework._
class WindowGraph extends AbstractClient {
var profile : ProfileInterface = _
var console : TextWindowInterface = _
var com : TextWindowInterface = _
var metric : TextWindowInterface = _
override def init(profileInterface: ProfileInterface, reloadData: ReloadData): Unit = {
profile = profileInterface
console = profile.getTextWindow("console")
com = profile.createTextWindow("com")
metric = profile.createTextWindow("metric")
val graph = new SplitWindow(
new WindowReference("console"),
new SplitWindow(
new WindowReference("com"),
new WindowReference("metric"),
false, 0.8f
),
true)
metric.setSplittable(false)
metric.setHighlightable(false)
com.setTextFont(new Font("Courier", 0, 36))
com.setTopColorScheme("bright")
profile.setWindowGraph(graph)
com.echo("hello")
com.echo("hello2")
com.setLine(10, "line ten")
com.setLine(8, "line ten")
metric.echo("100 xpm")
}
override def handleCommand(cmd: String): Boolean = {
cmd match {
case "clear" =>
metric.clear()
true
case "unsplit" =>
console.unsplit()
true
case "split" =>
console.split()
true
case none => false
}
}
}
示例14: MyFont
//设置package包名称以及导入依赖的类
package de.sciss.schwaermen
import java.awt.Font
object MyFont {
private[this] lazy val _initFont: Font = {
val url = getClass.getResource("/OpenSans-CondLight.ttf")
require(url != null)
val is = url.openStream()
val res = Font.createFont(Font.TRUETYPE_FONT, is)
is.close()
res
}
private[this] var _condensedFont: Font = _
def apply(): Font = {
if (_condensedFont == null) _condensedFont = _initFont
_condensedFont
}
def apply(size: Float): Font = apply().deriveFont(size)
}
示例15: Colors
//设置package包名称以及导入依赖的类
package MicrowaveOvenSPL.microwavegui
import java.awt.{ Color => aColor }
import java.awt.Font
import scala.swing.Swing
import java.awt.{Color => aColor}
object Colors {
val bluish = new aColor(32, 178, 170)
val brownLight = new aColor(140, 137, 132)
val magenta = new aColor(255, 0, 255)
val indigo = new aColor(75, 0, 130)
val white = new aColor(255, 255, 255)
val black = new aColor(0, 0, 0)
val orange = new aColor(255, 102, 0)
val yellow = new aColor(255, 255, 0)
val hiri = new aColor(102, 102, 102)
val blue = new aColor(0, 51, 102)
val violet = new aColor(238, 130, 238)
val plum = new aColor(221, 160, 221)
val lightbr = new aColor(255, 255, 153)
val pink = new aColor(216,191,216)
}
object Fonts {
val thefont = new Font("Verdana", Font.BOLD, 14)
val tafont = new Font("Verdana", Font.CENTER_BASELINE, 11)
val bluishborder = Swing.LineBorder(Colors.bluish)
}