我的问题是我想在一个面板中绘制一条虚线,我能够做到这一点,但它也用虚线绘制我的边框,这是我的天啊!
有人可以解释一下原因吗?我正在使用paintComponent直接绘制并绘制到面板
这是绘制虚线的代码:
public void drawDashedLine(Graphics g, int x1, int y1, int x2, int y2){
Graphics2D g2d = (Graphics2D) g;
//float dash[] = {10.0f};
Stroke dashed = new BasicStroke(3, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[]{9}, 0);
g2d.setStroke(dashed);
g2d.drawLine(x1, y1, x2, y2);
}
Run Code Online (Sandbox Code Playgroud) 目前我正在学习HTML/CSS,我想用Windows 8风格(metro风格)创建一个博客.但我在禁用溢出时遇到问题.我正在使用<body>html中的表格,每个表格数据都有固定大小.但是每当我在表中的一行中添加一个单元格时,如果该行在x方向上溢出,那么该单元格会自动跳转.
反正有没有避免这个?
这是我的代码的一部分:
CSS:
/***Creating the dashboard in metro style***/
.dashboard {
position: fixed;
top: 10.5em;
left: 0;
padding-top: 1em;
padding-left: 1em;
padding-bottom: 1em;
border: 5px solid white;
overflow-x: scroll;
overflow-y:hidden;
}
td {
border: 3px solid yellow;
float: left;
margin: 0;
color: black;
width: 300px;
font-size: 1.5em;
cursor: pointer;
position: relative;
background-color: white;
}
.tile-1{
background-color: #56d9c9;
color: white;
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<div class="dashboard">
<table style="border: 1px solid red">
<tr>
<td><p>I just got you babe 1</p></td>
<td><p>I …Run Code Online (Sandbox Code Playgroud) 我对 Angular 非常陌生,目前我正在学习 Angular 6,它是 Angular 的最新版本。
在这里,我尝试使用从 JSON 检索的文章来设计我的博客页面,并将它们显示在两列中,如下图所示:
标题旁边的数字是文章数组中文章的索引。很容易看出问题:从 1 开始的索引被重复两次。
这是我的代码,请告诉我为什么我的细节错误以及如何修复它。
博客服务:
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Injectable({
providedIn: 'root'
})
export class BlogService {
constructor(private http: HttpClient) { }
getArticleList() {
return this.http.get('https://jsonplaceholder.typicode.com/posts');
}
}
Run Code Online (Sandbox Code Playgroud)
文章列表组件:
从 '@angular/core' 导入 { Component, OnInit }; 从'../blog.service'导入{BlogService};
@Component({
selector: 'app-blog',
templateUrl: './article-list.component.html',
styleUrls: ['./article-list.component.css']
})
export class ArticleListComponent implements OnInit {
articles: Object;
constructor(private data: BlogService) { }
ngOnInit() {
this.data.getArticleList().subscribe(
data …Run Code Online (Sandbox Code Playgroud) 我是Scheme编程的初学者.我知道Scheme中的点符号用于表示一对符号,例如'(a . b).
第一个元素可以是符号,也可以是列表,无关紧要.但特别是第二个元素必须是一个符号,如果不是,可能是一个列表,那么我们就不能创建一个内置cons过程的对.
那么有可能创建一对2列表??? 好吧,我正在考虑一个解决方案是将列表转换为符号,但实际上这些是完全不同的两件事 - >根据我的理解不可能.
这是我写的代码:
(define compare-attrs
(lambda (attribute1 attribute2)
(if (or (and (null? attribute1) (null? attribute2)) (and (not (null? attribute1)) (not (null? attribute2))))
(cons attribute1 attribute2)
#f)))
Run Code Online (Sandbox Code Playgroud)
其中attribute1和attribute2是2个列表,我的输出是:
attribute1 atrribute2
Run Code Online (Sandbox Code Playgroud)
预期输出:'(attribute1.attribute2)
请解释一下.预先感谢!!!
编辑:添加比较attrs功能的使用
函数compare-attrs用于提取描述实体属性的部分,并将cons它们组成一对,实体定义如下:
(entity e0 (prov:label "entity e0")
(entity e1 (prov:location "London")
Run Code Online (Sandbox Code Playgroud)
所以这些实体的属性是(prov:label "entity e0")和(prov:location "London").当应用函数compare-attrs时,因为这些属性不是null,所以我期望的输出是
`(prov:label "entity e0") . (prov:location "London")`
Run Code Online (Sandbox Code Playgroud) 当我尝试执行这段代码时:
\n\n((lambda (a) (cons (quote a) a)) \xe2\x80\x99(d a b))\nRun Code Online (Sandbox Code Playgroud)\n\n我收到错误:
\n\n\n\n\n\xe2\x80\x99:模块中的未绑定标识符:\xe2\x80\x99
\n
有人可以帮我解释一下吗?
\n我感觉非常愚蠢.但是为什么这段简单的代码不会改变椭圆的颜色呢?
基本上我想在椭圆上添加一个鼠标监听器 - 一个图形对象.当鼠标光标为椭圆形时,椭圆会改变其颜色.但是这段代码根本没有改变......这段代码仅供测试.
public class Help extends JFrame{
public static void main(String [] agrs){
Help h = new Help();
h.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
h.add(new Help_Option());
h.setSize(2000, 1000);
h.setVisible(true);
}
}
class Help_Option extends JComponent implements MouseListener{
Ellipse2D ellipse = new Ellipse2D.Double(0, 0, 1000, 500);
Color c = Color.BLACK;
public Help_Option(){
this.addMouseListener(this);
}
public void paintComponent(Graphics g){
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(Color.BLUE);
g2d.draw(ellipse);
g2d.setColor(c);
g2d.fill(ellipse);
}
public void setColor(Color c){
this.c = c;
}
@Override
public void mouseClicked(MouseEvent e) {
} …Run Code Online (Sandbox Code Playgroud) 这个 OpenGL 程序是为了绘制一个三角形而编写的,但它崩溃了。
基本上,一组三角形顶点被定义为名为坐标的数组,然后这个数组被传递到一个缓冲区,glDrawArrays 方法将根据模式 GL_TRIANGLES 从顶点 0 开始绘制三角形,总共 3 个顶点。
我对吗?有人可以告诉我错误在哪里吗?这是代码:
// Open an OpenGL window
GLFWwindow* window;
int k = 0;
/****Step 1: define vertices in (x, y, z) form****/
const GLfloat coordinates[] = {
-1.0f, -1.0f, 0.0f,
1.0f, -1.0f, 0.0f,
0.0f, 1.0f, 0.0f
};
/************************/
/**Step 2: send this triangle vertices to OpenGL through a buffer**/
GLuint vertexBuffer; // identify vertex buffer
void Render(void){
/************************/
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
glVertexAttribPointer(0, 3 /*size*/, GL_FLOAT /*type*/, GL_FALSE, 0, (void*)0);
glDrawArrays(GL_TRIANGLES, …Run Code Online (Sandbox Code Playgroud)