小编Moh*_*iri的帖子

如何绘制表示连接节点图的树?

我想在Java GUI中显示一个树,但我不知道如何.树表示连接节点的图形,如下所示:

图片

我应该说我有自己的树类:

public class BinaryTree  
{
private BinaryNode root;
public BinaryTree( )
{
    root = null;
}

public BinaryTree( Object rootItem )
{
    root = new BinaryNode( rootItem, null, null );
}

public BinaryTree( Object rootItem,BinaryNode a,BinaryNode b )
{
    root = new BinaryNode( rootItem, a, b );
}

public int leavesCount(){
    return BinaryNode.leavesCount(root);
}

public boolean equal(BinaryTree a,BinaryTree b){
    return BinaryNode.equal(a.root, b.root);

}

public void printPreOrder( )
{
    if( root != null )
        root.printPreOrder( );
}

public void …
Run Code Online (Sandbox Code Playgroud)

java swing swt awt

12
推荐指数
2
解决办法
3万
查看次数

如何使用Http Post从WebView检索和修改HTML内容

我正在开发一个显示HTML页面某些部分的Android应用程序.第一步,我使用此代码提供的代码如何从WebView检索HTML内容.

  • 完整的HTML图片

第1部分

  • 那部分我想表现出来

    第2部分

    /* An instance of this class will be registered as a JavaScript interface */
    class MyJavaScriptInterface
    {
        @SuppressWarnings("unused")
        public void processHTML(String html)
        {
            // process the html as needed by the app
        }
    }
    
    final WebView browser = (WebView)findViewById(R.id.browser);
    /* JavaScript must be enabled if you want it to work, obviously */
    browser.getSettings().setJavaScriptEnabled(true);
    
    /* Register a new JavaScript interface called HTMLOUT */
    browser.addJavascriptInterface(new MyJavaScriptInterface(), "HTMLOUT");
    
    /* WebViewClient must be set BEFORE calling loadUrl! */
    browser.setWebViewClient(new …
    Run Code Online (Sandbox Code Playgroud)

html java android webview

11
推荐指数
1
解决办法
2339
查看次数

使用asp.net身份在身份服务器4中实现角色

我正在使用身份服务器4作为令牌服务的asp.net MVC应用程序.我有一个api,它有一些安全的资源.我想为api实现角色(授权).我想确保只有具有有效角色的授权资源才能访问api端点,否则会获得401(未经授权的错误).

这是我的配置:

客户

         new Client()
            {
                ClientId = "mvcClient",
                ClientName = "MVC Client",                    
                AllowedGrantTypes = GrantTypes.HybridAndClientCredentials,

                ClientSecrets = new List<Secret>()
                {
                    new Secret("secret".Sha256())
                },

                RequireConsent = false;

                // where to redirect to after login
                RedirectUris = { "http://localhost:5002/signin-oidc" },
                // where to redirect to after logout
                PostLogoutRedirectUris = { "http://localhost:5002" },

                AllowedScopes =
                {
                    StandardScopes.OpenId.Name,
                    StandardScopes.Profile.Name,
                    StandardScopes.OfflineAccess.Name,
                    StandardScopes.Roles.Name,
                    "API"
                }
            }
Run Code Online (Sandbox Code Playgroud)

领域

 return new List<Scope>()
            {
                StandardScopes.OpenId, // subject id
                StandardScopes.Profile, // first name, last name
                StandardScopes.OfflineAccess,  // requesting …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-identity asp.net-core-1.0 identityserver4

10
推荐指数
1
解决办法
9495
查看次数

使用 ffmpeg 解密 AES-128 加密的 .m3u8 播放列表和 .TS 文件

我正在尝试解密.m3u8播放列表,我按照以下步骤操作:

  • 创建一个目录
  • 将密钥复制到密钥文件,即my.key,并将其放在目录中。请注意,如果播放列表有多个键,则可以旋转键,将它们全部复制到不同的文件中。
  • 将所有.ts段复制到同一目录
  • 复制并编辑playlist.m3u8并仅使用键 URI 和段的文件名。

并使用此命令解密播放列表

ffmpeg -i playlist.m3u8 -c copy output.ts
Run Code Online (Sandbox Code Playgroud)

但我收到了这个错误:Invalid data found when processing input

这是我的 m3u8 :

#EXTM3U
#EXT-X-TARGETDURATION:12
#EXT-X-ALLOW-CACHE:YES
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-KEY:METHOD=AES-128,URI="my.key"
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:1
#EXTINF:6.000,
s-1-v1-a1.ts
#EXTINF:6.000,
s-2-v1-a1.ts
#EXTINF:6.000,
s-3-v1-a1.ts
#EXTINF:12.000,
s-4-v1-a1.ts
#EXTINF:12.000,
s-5-v1-a1.ts
#EXTINF:6.000,
s-6-v1-a1.ts
#EXT-X-ENDLIST
Run Code Online (Sandbox Code Playgroud)
  • 我的命令有什么问题吗?
  • 如何不将播放列表转换为一个.TS文件?我想单独解密文件

streaming ffmpeg http-live-streaming

8
推荐指数
1
解决办法
3万
查看次数

程序,可执行文件和进程之间的区别是什么?

我想知道程序,可执行文件和进程之间的区别是什么?

unix operating-system

6
推荐指数
2
解决办法
2万
查看次数

具有ASP.NET Core身份的Web API的IdentityServer4基于角色的授权

我正在将IdentityServer4与.Net Core 2.1和Asp.Net Core标识一起使用。我的解决方案中有两个项目。

  • 身份服务器
  • 网络API

我想保护我的Web API,我使用邮差请求新的令牌,它可以正常工作并且令牌已成功生成。当我[Authorize]在没有角色的控制器上使用时 ,它可以完美工作,但是当我使用[Authorize(Roles="Student")](甚至与[Authorize(Policy="Student")])一起使用时 ,它总是返回403 forbidden

完整代码的Github链接:https : //github.com/Mohammad7070/ShagerdanehIdentityServer

我的代码有什么问题

Web API startup.cs

  public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {



            services.AddMvcCore()
            .AddAuthorization(options => options.AddPolicy("Student", policy => policy.RequireClaim("Role", "Student")))
            .AddAuthorization(options => options.AddPolicy("Teacher", policy => policy.RequireClaim("Role", …
Run Code Online (Sandbox Code Playgroud)

c# asp.net asp.net-identity asp.net-core identityserver4

6
推荐指数
2
解决办法
4030
查看次数

如何将子项添加到n-array树中的特定节点?

我写了这个n-array树类现在我想编写一个方法来将一个子节点添加到我树中的特定节点,方法是:首先我应该搜索我的树找到父亲,然后将子节点添加到该节点.我不知道如何申报我的方法

public class FamilyNode {
    public String name;
    public String Family;
    public String sex;
    public FamilyNode Father;
    public FamilyNode Mother;
    public FamilyNode Spouse=null;
    public String status="alive";
    public int population;
    public ArrayList<FamilyNode> children=new ArrayList<FamilyNode>() ;


    public FamilyNode(String firstname,String lastname,String sex1){
        this.name=firstname;
        this.Family=lastname;
        this.sex=sex1;
        this.population=this.children.size()+1;
    }

    public void SetParents(FamilyNode father,FamilyNode mother){
        this.Father=father;
        this.Mother=mother;
    }

    public void SetHW(FamilyNode HW){
        this.Spouse=HW;
    }

    public int Number (){
        int number_of_descendants = this.population;

        if(this.Spouse!=null) number_of_descendants++;

        for(int index = 0; index < this.children.size(); index++)
            number_of_descendants = number_of_descendants+ this.children.get(index).Number(); …
Run Code Online (Sandbox Code Playgroud)

java arrays tree search

5
推荐指数
1
解决办法
4867
查看次数