java – How does Android’s freeform window system work?

I have this idea for creating a Samsung DeX like experience, but without having a Samsung phone. For example, an LG phone that when docked, displays a desktop like interface to the user on another display, and when undocked, it returns back to the phones screen.

Android seems to have something like this already. However, I cannot seem to find any documentation on how the freeform window system works. More specifically, how does it create the activities and put them into windows with decorations.

How does Android do this?

java – Access denied to AppRegNew.aspx page in SharePoint

When I try to open ‘https://{site}/_layouts/15/AppRegNew.aspx’, in order to generate an access token to authorize REST API calls to the SharePoint site to retrieve data and manipulate the site data, I get the below message even though I have admin access:

Sorry, you don’t have access.

So, Are there any other ways to generate access token other than the steps mentioned here.

Or Is there any extra permission needed to get access to this page? or do we have to change any settings to get this access?

Is this Java Application correct?

Aim: Write a Menu driven program in java to implement simple banking
applications. Application should read the customer name, account number, initial
balance, rate of interest, contact number and address field etc. The application should
have.
following methods.

  1. createAccount() 2. deposit() 3. withdraw()
  2. computeInterest() 5. displayBalance()

Code:

interface Bank {

float rate = 12.0f;
int no_of_years=3;
void displayBalance();

}
class Customer {

String cust_name;
int cust_id;
Customer(String n,int i) {

cust_name = n;
cust_id = i;

}
void createAccount() {

System.out.println("Customer Name = "+cust_name);
System.out.println("Customer Id = "+cust_id);
}

}
class Account extends Customer implements Bank {

int acc_no;
float acc_bal;
Account(String n,int b,int x,float y) {
super(n,b);
acc_no=x;
acc_bal=y;

}
public void displayBalance() {

createAccount();
System.out.println("Account No. = "+acc_no);
System.out.println("Account Balance = "+acc_bal);

}
void computeIntrest() {

displayBalance();
float intr = (rate*acc_bal*no_of_years)/100;
System.out.println("Rate of Interest = "+intr);
}

}

public class Exp4java {

public static void main (String() args)
{
Account ac = new Account("Frason",8,4444,8000);
ac.computeIntrest();
}

}

java – MIDI editor application

Source

I made a project for a class, a MIDI editor written with Java 8 and Swing, and continued working on it on my own. However, I ran into a problem I couldn’t solve and gave up.

I’d like feedback on high level design/architecture, things like cohesion, coupling etc between classes. I’m pretty sure the project is weak in this regard. Would MVC be appropriate here?

I’m also concerned about the model. I made it so that a composition has a list of measures, and a measure has a list of notes, but I think that was hard to work with and caused issues. Maybe a map data structure would have been better. The class for reading midi files became really complicated because I didn’t model sequences and tracks.

The problem I couldn’t solve was synchronizing the movement of the progress line and the audio playback. I know the focus of this site isn’t to debug, so you don’t have to comment on that.

Please feel free to offer any feedback at all also.

array – External Data Sources in Java: Code white out

The code I wrote in Java is meant to read a file that has numbers, and calculate max, min and avg.

input file:

min:1,2,3,4,5,6
max:1,2,3,4,5,6
avg:1,2,3,4,5,6

I wrote the the code (see below), however for some reason the code in my main turned white. When I undid, everything, it still remained white. I have no idea what I did or how to undo it. Please can someone help me.

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Formatter;
import java.util.Locale;

public class MyFile {
    
    

    
    //This class calculates the max of an array's elements
    public int max(int () integers) {
        int max = 0;
        
        for (int i=0; i<integers.length; i++) {
            if(integers(i)<max) {
                max = integers(i);
                
            }
        }
        return max;
        
    }
    
    //This class calculates the min of an array's elements
    public int min(int () integers) {
        int min = 0;
        
        for (int i=0; i<integers.length; i++) {
            if(integers(i)<min) {
                min = integers(i);
                
            }
        }
        return min;
        
    }
    
    //This class calculates the average of an array's elements
    public static double avg(int () integers) {
        double sum = avg(integers);
        return (double) sum /integers.length; 
    
    }
    
    
    //The Main Class
    public static void main(String() args) {
        
        //assign file address to string variable
        String path = "/Users/input.txt";
        String outputpath = "/Users/output.txt";
        
        try {
            //Read from file
            File x = new File(path);
            Scanner sc = new Scanner(x);
            
            //create empty file at specified path 
            Formatter f = new Formatter(outputpath);
            
            while(sc.hasNext()) {
                
                String data = sc.nextLine();
                String () lines = data.split(":");
                String () str = lines(1).split(",");
                
                //Convert string array to integer array
                int size = str.length;
                int () integers = new int (size);
                for(int i = 0; i<size; i++) {
                    integers(i) = Integer.parseInt(str(i));
                }
            
                
                
                if (lines(0).equals("min")) {
                    
                    System.out.println("The max of" + Arrays.toString(integers) + "is " max(integers));
                    
                }
                
                else if (lines(0).equals("min")) {
                    System.out.println("The min of" + Arrays.toString(integers) + "is " min(integers));
                    
                }
                
                else if (lines(0).equals("avg")) {
                    
                    System.out.println("The average of" + Arrays.toString(integers) + "is " avg(integers));
                    
                }
                System.out.println(sc.next());
                
            }
            sc.close();
            
        }
        
        catch (FileNotFoundException e) {
            System.out.println("Error");
        }
        
        catch (Exception e) {
            System.out.println("Error");
        }
        
        

    }

}

architecture – Integrating TeX into a Java desktop application

Looking to integrate TeX equations in a TeX-agnostic fashion, suitable for either ConTeXt or LaTeX, into a Java-based desktop Markdown editor. The possibilities are numerous, but I’m not sure what approach to take.

JMathTex outputs to MathML, which must be transformed. JEuclid can transform MathML to BufferedImages (not 100% sure). Neither are JDK 14-friendly and may be too slow to render in real-time. I haven’t looked because I read that they didn’t work with Java 9 (without porting effort), much less 14. Also, the licensing isn’t LGPL, which probably won’t work with the MIT licensing.

The NTS library is reported to compile gentle.tex in about 3 seconds. The spin-off project, εχTEX improves upon NTS, but I don’t know to what extent.

Java LaTeX Report requires a TeX engine.

Yet another possibility is to try JavaTex or rework the project using web2java to transpile WEB files into Java files.

JLaTeXMath does an exceptional job at rendering, though investigation would be required to see if it can perform real-time renders, output as SVG, or otherwise determine if it can integrate with FlyingSaucer.

The HTML preview panel uses FlyingSaucer. The SVG documents are rendered using SVG Salamander. If it was possible to go from TeX to SVG, that could work quite handily, architecturally. Some documentation stated FlyingSaucer can also render MathML, but I suspect the doc is wrong. FlyingSaucer doesn’t integrate with JavaScript. For that I’d have to add a JavaScript Engine.

If a JavaScript Engine is necessary, then using KaTeX may be an option.

Still another possibility is the TeX to MathML service. This is written in Java, but the source code is not available anywhere. I’ve reached out to some people involved in the project.

For native speeds, there may be a (cross-platform?) C-based TeX engine that can generate MathML or SVG from a TeX input. If so, it may be possible to integrate with the JNI.

Here’s a demo video of the app, to give you an idea of what is needed:

The goal is to produce real-time rendering of math, ideally in pure Java (no JavaScript).

What approach would you take and what do you see as its benefits and drawbacks?

java – Are there any tool/library etc. to go a website and then click a button to create dynamic html before parsing?

Sorry if the header seems a bit confusing.

Simply, I am parsing HTML of a website by using JSoup library of Java. The thing is, the HTML is dynamically created in that website. My code should first click “Load More” button in the website and then parse the HTML. I couldn’t figure out how to do this.

I found out that HTML Unit or Selenium is related with this problem but I want to indicate a difference. I don’t want my browser to be opened and then a buttun clicked and I guess this is what these tools do.

spring – Elastic search Java

Below is a json schema I have in elastic search

{
    "fullName": "",
    "avatar": "",
    "email": "",
    "resumeLink": "",
    "phone": "",
    "role": "",
    "noticePeriod": "",
    "dateOfBirth": "",
    "gender": "",
    "maritalStatus": "",
    "address": "",
    "location": "",
    "industryType": "",
    "personalSummary": "",
    "workSummary": "",
    "functionalArea": "",
    "currentPosition": "",
    "currentEmployer": "",
    "keySkills": (),
    "otherSkills": (),
    "iTSkill": (
      {
        "skill": "",
        "version": ""
      }
    ),
    "highestEducationDetails": "",
    "educationDetails": {
      "Under graduation": {
        "school": "",
        "degreeType": ""
      },
      "Post graduation": {
        "school": "",
        "degreeType": ""
      }
    }
  }

Below is a boolean query i wrote in java to search for keywords, and also search individual fields like Location, Role, addresses, skills and other fields in the json schema returnning a random_score for the documents

  if (Strings.isEmpty(searchQueryRequest.getText())) {
                query = QueryBuilders.functionScoreQuery(QueryBuilders.matchAllQuery(), ScoreFunctionBuilders.randomFunction());//This line does not return random result;



            } else {
                query = QueryBuilders.boolQuery()
                        //.minimumShouldMatch(1)
                        .should(QueryBuilders.functionScoreQuery(QueryBuilders.simpleQueryStringQuery(searchQueryRequest.getText()).field("location")
                                .defaultOperator(Operator.OR), ScoreFunctionBuilders.randomFunction()))
                        .should(QueryBuilders.functionScoreQuery(QueryBuilders.matchPhraseQuery("location", searchQueryRequest.getText()),
                                ScoreFunctionBuilders.randomFunction()))
                        
                        .should(QueryBuilders.functionScoreQuery(QueryBuilders.simpleQueryStringQuery(searchQueryRequest.getText()).field("role")
                                .defaultOperator(Operator.OR), ScoreFunctionBuilders.randomFunction()))
                        .should(QueryBuilders.functionScoreQuery(QueryBuilders.matchPhraseQuery("role", searchQueryRequest.getText()),
                                ScoreFunctionBuilders.randomFunction()))


                        .should(QueryBuilders.functionScoreQuery(QueryBuilders.simpleQueryStringQuery(searchQueryRequest.getText()).field("functionalArea")
                                .defaultOperator(Operator.OR), ScoreFunctionBuilders.randomFunction()))
                        .should(QueryBuilders.functionScoreQuery(QueryBuilders.matchPhraseQuery("functionalArea", searchQueryRequest.getText()),
                                ScoreFunctionBuilders.randomFunction()))


                        .should(QueryBuilders.functionScoreQuery(QueryBuilders.simpleQueryStringQuery(searchQueryRequest.getText()).field("workHistory.organization")
                                .defaultOperator(Operator.OR), ScoreFunctionBuilders.randomFunction()))
                        .should(QueryBuilders.functionScoreQuery(QueryBuilders.matchPhraseQuery("workHistory.organization", searchQueryRequest.getText()),
                                ScoreFunctionBuilders.randomFunction()))


                        .should(QueryBuilders.functionScoreQuery(QueryBuilders.simpleQueryStringQuery(searchQueryRequest.getText()).field("workHistory.designation")
                                .defaultOperator(Operator.OR), ScoreFunctionBuilders.randomFunction()))
                        .should(QueryBuilders.functionScoreQuery(QueryBuilders.matchPhraseQuery("workHistory.designation", searchQueryRequest.getText()),
                                ScoreFunctionBuilders.randomFunction()))


                        .should(QueryBuilders.functionScoreQuery(QueryBuilders.simpleQueryStringQuery(searchQueryRequest.getText()).field("keySkills")
                                .defaultOperator(Operator.OR), ScoreFunctionBuilders.randomFunction()))
                        .should(QueryBuilders.functionScoreQuery(QueryBuilders.simpleQueryStringQuery(searchQueryRequest.getText()).field("otherSkills")
                                .defaultOperator(Operator.OR), ScoreFunctionBuilders.randomFunction()))

                        .should(QueryBuilders.functionScoreQuery(QueryBuilders.simpleQueryStringQuery(searchQueryRequest.getText()).field("itSkill.skill")
                                .defaultOperator(Operator.OR), ScoreFunctionBuilders.randomFunction()))
                        
                        
                        .should(QueryBuilders.functionScoreQuery(QueryBuilders.simpleQueryStringQuery(searchQueryRequest.getText()).field("industryType")
                                .defaultOperator(Operator.OR), ScoreFunctionBuilders.randomFunction()))


                        .should(QueryBuilders.functionScoreQuery(QueryBuilders.matchPhraseQuery("industryType", searchQueryRequest.getText()),
                                ScoreFunctionBuilders.randomFunction()))


                        .should(QueryBuilders.functionScoreQuery(QueryBuilders.simpleQueryStringQuery(searchQueryRequest.getText())
                                .field("educationDetails.Under graduation.school")
                                .defaultOperator(Operator.OR), ScoreFunctionBuilders.randomFunction()))


                        .should(QueryBuilders.functionScoreQuery(QueryBuilders.matchPhraseQuery("educationDetails.Under graduation.school", searchQueryRequest.getText()),
                                ScoreFunctionBuilders.randomFunction()))

                        
                        .should(QueryBuilders.functionScoreQuery(QueryBuilders.simpleQueryStringQuery(searchQueryRequest.getText())
                                .field("educationDetails.Under graduation.degreeType")
                                .defaultOperator(Operator.OR), ScoreFunctionBuilders.randomFunction()))

                        
                        .should(QueryBuilders.functionScoreQuery(QueryBuilders.matchPhraseQuery("educationDetails.Under graduation.degreeType", searchQueryRequest.getText()),
                                ScoreFunctionBuilders.randomFunction()))

                        
                        .should(QueryBuilders.functionScoreQuery(QueryBuilders.simpleQueryStringQuery(searchQueryRequest.getText())
                                .field("educationDetails.Post graduation.school")
                                .defaultOperator(Operator.OR), ScoreFunctionBuilders.randomFunction()))


                        .should(QueryBuilders.functionScoreQuery(QueryBuilders.matchPhraseQuery("educationDetails.Post graduation.school", searchQueryRequest.getText()),
                                ScoreFunctionBuilders.randomFunction()))


                        .should(QueryBuilders.functionScoreQuery(QueryBuilders.simpleQueryStringQuery(searchQueryRequest.getText())
                                .field("educationDetails.Post graduation.degreeType")
                                .defaultOperator(Operator.OR), ScoreFunctionBuilders.randomFunction()))

                        
                        .should(QueryBuilders.functionScoreQuery(QueryBuilders.matchPhraseQuery("educationDetails.Post graduation.degreeType", searchQueryRequest.getText()),
                                ScoreFunctionBuilders.randomFunction()));
            }

How can i make this better?

capturar los marcadores de estaciones por la ruta trazada en la busquedad con la api de google maps java script

como identifico las estaciones marcadas por la ruta escogida

como identifico las estaciones marcadas por la ruta escogida

java – Incorporating HttpSession into libGDX communication

I wrote my server-side code prior to learning libGDX and writing my client-side code. Gdx.net provides for the http get communication I designed for, except for session authentication. I say that based on not finding sessions mentioned in the API, and a couple heavies confirming it on the libGDX discord.

Are there any libraries / examples out there of libGDX developers who mirrored session authentication functionality? The key limitation here is I want to stay with http request/response communication.


Minus any such direction, my next step will be to try using the “javax.servlet” libraries I used server-side on the client, and forgo the http classes that come included in the Gdx.net package. I’m reluctant to take this step noting that libGDX has its own versions of lots of classes, for efficiency and to prevent memory leaks given how libGDX programs execute. It’ll be a while yet before my programming skills can detect and address such subtle issues. Also, I think that browsers and the server servlets run on participate in session architecture. With neither component in a libGDX PC app for “javax.servlet” to collaborate with, I’m doubtful this solution can work.

If it doesn’t work, I’ll think about moving up my goal of researching and learning how to use cloud hosting services. Some of these were recommended to me on discord as having frameworks with built-in support for authentication.