我有一个需要使用线和框(将包含一条消息)识别的 div,如下面的模型图像所示。 2 和 3(线和矩形框)彼此固定并且可拖动和 1(线)可以向任何方向拉伸。我已经创建了这个盒子,但我不知道如何在它上面附加一条线。这是我尝试过的。
js
const $b1 = $("#box1");
const $b2 = $("#box2");
const $line = $("#line");
const coordinates = function() {
debugger;
const x1 = $b1.offset().left;
const y1 = $b1.offset().top + $b1.height()/2;
const x2 = $b2.offset().left + $b1.width()/2;
const y2 = $b2.offset().top + $b1.height()/2;
moveLine(x1, y1, x2, y2);
}
coordinates();
function moveLine(x1, y1, x2, y2) {
var length = Math.sqrt(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)));
var angle …Run Code Online (Sandbox Code Playgroud) class A{
String z(){
System.out.println("a");
return "sauarbh";
}
}
class B{
A a;
A x(){
return a;
}
}
public class runner {
public static void main(String[] args) {
B b = new B();
A a2=b.x();
a2.z(); // Calling A class method without creating object of it
}
}
Run Code Online (Sandbox Code Playgroud)
另一个例子
class Person
{
private String lastName;
private String firstName;
private int age;
//--------------------------------------------------------------
public Person(String last, String first, int a)
{ // constructor
lastName = last;
firstName = first;
age …Run Code Online (Sandbox Code Playgroud)