• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala BasicStroke类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Scala中java.awt.BasicStroke的典型用法代码示例。如果您正苦于以下问题:Scala BasicStroke类的具体用法?Scala BasicStroke怎么用?Scala BasicStroke使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了BasicStroke类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。

示例1: TransparentTest

//设置package包名称以及导入依赖的类
package de.sciss.schwaermen

import java.awt.{BasicStroke, Color, Graphics, Graphics2D}

import scala.swing.Swing

object TransparentTest {
  def main(args: Array[String]): Unit = {
    Swing.onEDT(run())
  }

  def run(): Unit = {
    val frame = new javax.swing.JFrame("Test")
    frame.setUndecorated(true)
    frame.setBackground (new Color(0,0,0,0))
    frame.setContentPane(new TestComponent())
    frame.pack()
    frame.setSize(500, 500)
    frame.setLocationRelativeTo(null)
    frame.setVisible(true)
  }

  final class TestComponent extends javax.swing.JComponent {
    override def paintComponent(g: Graphics): Unit = {
      super.paintComponent(g)
      g.setColor(Color.red)
      val g2 = g.asInstanceOf[Graphics2D]
      g2.setStroke(new BasicStroke(3f))
      g.drawLine(0, 0, getWidth, getHeight)
      g.drawLine(0, getHeight, getWidth, 0)
    }
  }
} 
开发者ID:Sciss,项目名称:Schwaermen,代码行数:34,代码来源:TransparentTest.scala


示例2: timeTo

//设置package包名称以及导入依赖的类
package things

import java.awt.{BasicStroke, Color, Graphics2D}

trait Wall extends Thing {
  val p: Double
  val dir: Int

  def timeTo(mov: Movable) = {
    val v = mov.vel(dir)
    val dist = if (p < 0) p - mov.pos(dir) + mov.r else p - mov.pos(dir) - mov.r
    val timeToHit = if (v == 0) Double.PositiveInfinity else dist / v
    if (timeToHit <= 0) Double.PositiveInfinity else timeToHit
  }
}

case class VWall(p: Double) extends Wall {
  val id = Int.MaxValue
  val dir = 0

  def draw(g: Graphics2D) {
    g.setColor(new Color(255, 0, 255))
    g.setStroke(new BasicStroke(3f))
    line(g)(p, -3000, p, 3000)
  }
}

case class HWall(p: Double) extends Wall {
  val id = Int.MaxValue
  val dir = 1

  def draw(g:Graphics2D) {
    g.setColor(new Color(255, 0, 255))
    g.setStroke(new BasicStroke(3f))
    line(g)(-3000, p, 3000, p)
  }
} 
开发者ID:davips,项目名称:mucel-scala,代码行数:38,代码来源:Wall.scala


示例3: updateBounds

//设置package包名称以及导入依赖的类
package ch.santosalves.neurosimulator.ui

import javax.swing.JComponent
import java.awt.Graphics
import javax.swing.BorderFactory
import java.awt.Color
import java.awt.event.ComponentAdapter
import java.awt.event.ComponentEvent
import org.apache.logging.log4j.LogManager
import javax.swing.JPanel
import java.awt.Graphics2D
import java.util.Observable
import ch.santosalves.neurosimulator.api.ObservableObject
import ch.santosalves.neurosimulator.api.OutputTrigged
import ch.santosalves.neurosimulator.api.NerveCell
import java.util.Observer
import java.awt.BasicStroke


  def updateBounds = {
    val _b = (n1.getX <= n2.getX) match {
      case true => (n1.getY <= n2.getY) match {
        case true  => new BoundingBox(n1.getX, n1.getY, n2.getX, n2.getY, 1)
        case false => new BoundingBox(n1.getX, n2.getY, n2.getX, n1.getY, 4)
      }
      case false => (n1.getY <= n2.getY) match {
        case true  => new BoundingBox(n2.getX, n1.getY, n1.getX, n2.getY, 2)
        case false => new BoundingBox(n2.getX, n2.getY, n1.getX, n1.getY, 3)
      }
    }
    
    bbox = _b.reMap(16, 16)
    setBounds(bbox.minX, bbox.minY, bbox.getWidth, bbox.getHeight)
    //logger.info("[" + name + "](x1,y1)->(x2,y2) => (" + bbox.minX + "," + bbox.minY + ")->(" + bbox.maxX + ", " + bbox.maxY + ")")
  }

  override def paint(g: Graphics) = {
    val c = g.getColor
    g.setXORMode(Color.WHITE)    
    
    g.setColor(wireColor)      
    g.asInstanceOf[Graphics2D].setStroke(new BasicStroke(2))
    bbox.quadrant match {
      case 1 => g.drawLine(0, 0, bbox.getWidth, bbox.getHeight)
      case 3 => g.drawLine(0, 0, bbox.getWidth, bbox.getHeight)
      case 2 => g.drawLine(0, bbox.getHeight, bbox.getWidth, 0)
      case 4 => g.drawLine(0, bbox.getHeight, bbox.getWidth, 0)
    }    
    
    g.setColor(c)
    
    super.paint(g)
    
  }
} 
开发者ID:sergio-alves,项目名称:NeuroSimulator,代码行数:56,代码来源:NeuronLink.scala


示例4: PeriodicTable

//设置package包名称以及导入依赖的类
package widgets

import java.awt.{Font, BasicStroke, Color, Rectangle}

import atom.Atom

import scala.swing._
import scala.swing.event.MouseClicked


class PeriodicTable extends Panel {
  private var _value:Atom = Atom.C
  def value = _value
  def value_=(v:Atom) = {
    _value = v
    peer.paintImmediately(new Rectangle(size))
  }
  override def paint(graphics : Graphics2D): Unit = {
    val font:Font = new Font("Arial", Font.BOLD, 16)
    graphics.setFont(font)
    val fontMetrics = graphics.getFontMetrics
    for (atom:Atom <- Atom.atoms) {
      val left = (atom.group - 1) * size.width / 18
      val top = (atom.period - 1) * size.height / 5
      val right = atom.group * size.width/18
      val bottom = atom.period * size.height/5
      graphics.setPaint(atom.color)
      graphics.setStroke(new BasicStroke(1))
      graphics.fillRect(left, top, right-left, bottom-top)
      graphics.setPaint(Color.BLACK)
      graphics.drawString(
        atom.symbol,
        left+(size.width/18-fontMetrics.stringWidth(atom.symbol))/2,
        bottom-(size.height/5-fontMetrics.getAscent())/2)
      if (_value == atom) {
        graphics.setStroke(new BasicStroke(4))
        graphics.drawLine(left+2, top+2, right-2, top+2)
        graphics.drawLine(left+2, top+2, left+2, bottom-2)
        graphics.drawLine(left+2, bottom-2, right-2, bottom-2)
        graphics.drawLine(right-2, top+2, right-2, bottom-2)
      }
    }
  }
  listenTo(mouse.clicks, mouse.moves, mouse.wheel)
  reactions += {
    case event: MouseClicked => {
      val group = event.point.x / (size.width / 18) + 1
      val period = event.point.y / (size.height / 5) + 1
      value = Atom(group, period) match {
        case Some(atom) => atom
        case None => value
      }
    }
  }
  preferredSize = new Dimension(400, 200)
  maximumSize = new Dimension(800,200)
} 
开发者ID:ReactionMap,项目名称:RMapViewerS,代码行数:58,代码来源:PeriodicTable.scala



注:本文中的java.awt.BasicStroke类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala TreeSet类代码示例发布时间:2022-05-23
下一篇:
Scala RecyclerView类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap